:root {
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --color-primary: #4f46e5;
    --color-primary-dark: #3730a3;
    --color-sidebar-bg: #1e1b4b;
    --color-sidebar-text: #c7d2fe;
    --color-sidebar-hover: rgba(255,255,255,0.08);
    --color-sidebar-active: rgba(99,102,241,0.3);
    --color-bg: #f8fafc;
    --color-card: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-muted: #64748b;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--color-bg); color: var(--color-text); }

/* ── App layout ── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.sidebar-brand i { color: #818cf8; font-size: 1.5rem; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #818cf8, #6366f1);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.875rem;
    flex-shrink: 0;
}
.user-name { color: #fff; font-size: 0.875rem; font-weight: 600; }
.user-role { color: var(--color-sidebar-text); font-size: 0.75rem; }

.sidebar-nav { list-style: none; padding: 1rem 0; flex: 1; }
.nav-section {
    color: rgba(199,210,254,0.5);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.75rem 1.5rem 0.25rem;
}
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 0;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover { background: var(--color-sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--color-sidebar-active);
    color: #fff;
    border-left-color: #818cf8;
    font-weight: 600;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 1rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-toggle { background: none; border: none; color: var(--color-sidebar-text); font-size: 1.25rem; cursor: pointer; padding: 0.25rem; }

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-title { font-size: 1.125rem; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

.flash-container { padding: 0 1.5rem; padding-top: 1rem; }
.page-content { padding: 1.5rem; flex: 1; }

/* ── Cards ── */
.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 0.9375rem;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* ── Stats cards ── */
.stat-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #d1fae5; color: #059669; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { color: var(--color-muted); font-size: 0.8125rem; margin-top: 2px; }

/* ── Project cards ── */
.project-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: block;
}
.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--project-color, var(--color-primary));
}
.project-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); color: inherit; }
.project-card .project-name { font-weight: 700; font-size: 1rem; margin-bottom: 0.25rem; }
.project-card .project-summary { color: var(--color-muted); font-size: 0.85rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-card .project-meta { margin-top: 0.875rem; display: flex; align-items: center; gap: 0.5rem; }

/* ── Status badges ── */
.badge-status { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.25rem 0.625rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-active   { background: #d1fae5; color: #065f46; }
.badge-paused   { background: #fef3c7; color: #92400e; }
.badge-completed{ background: #dbeafe; color: #1e40af; }
.badge-archived { background: #f1f5f9; color: #475569; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-high  { background: #fee2e2; color: #991b1b; }
.badge-medium{ background: #fff7ed; color: #9a3412; }
.badge-low   { background: #f0fdf4; color: #166534; }

/* ── Tables ── */
.table-clean { width: 100%; border-collapse: collapse; }
.table-clean th { background: #f8fafc; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted); padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border); }
.table-clean td { padding: 0.875rem 1rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; font-size: 0.9rem; }
.table-clean tr:last-child td { border-bottom: none; }
.table-clean tr:hover td { background: #fafafa; }

/* ── Milestones ── */
.milestone-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}
.milestone-item:last-child { border-bottom: none; }
.milestone-step {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
    flex-shrink: 0;
}
.milestone-step.pending     { background: #fef3c7; color: #92400e; border: 2px solid #fbbf24; }
.milestone-step.in_progress { background: #dbeafe; color: #1e40af; border: 2px solid #60a5fa; }
.milestone-step.completed   { background: #d1fae5; color: #065f46; border: 2px solid #34d399; }
.milestone-connector { width: 2px; background: var(--color-border); margin: 4px 0 0 13px; height: 20px; }

/* ── Notes ── */
.note-card {
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.note-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--note-color, #fbbf24); }
.note-card:hover { box-shadow: var(--shadow-lg); }
.note-title { font-weight: 700; margin-bottom: 0.5rem; }
.note-content { color: var(--color-muted); font-size: 0.875rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { margin-top: 0.75rem; font-size: 0.75rem; color: var(--color-muted); }

/* ── Todos ── */
.todo-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid #f1f5f9; }
.todo-item:last-child { border-bottom: none; }
.todo-item.completed .todo-title { text-decoration: line-through; color: var(--color-muted); }
.todo-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--color-border); cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.15s; background: transparent; }
.todo-check.checked { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.todo-title { font-size: 0.9rem; flex: 1; }
.todo-due { font-size: 0.75rem; color: var(--color-muted); }
.todo-due.overdue { color: #dc2626; }

/* ── Forms ── */
.form-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.form-label { font-size: 0.875rem; font-weight: 600; color: var(--color-text); margin-bottom: 0.375rem; display: block; }
.form-control, .form-select {
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    padding: 0.5625rem 0.875rem;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    background: #fff;
    color: var(--color-text);
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
textarea.form-control { resize: vertical; min-height: 100px; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.5rem 1rem; border-radius: 8px;
    font-size: 0.875rem; font-weight: 600;
    border: 1.5px solid transparent;
    cursor: pointer; text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn-icon { padding: 0.4rem; width: 32px; height: 32px; justify-content: center; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--color-muted); }
.empty-state i { font-size: 3rem; opacity: 0.3; display: block; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* ── Color picker ── */
.color-option { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: all 0.15s; }
.color-option.selected, .color-option:hover { border-color: rgba(0,0,0,0.3); transform: scale(1.15); }

/* ── Document list ── */
.doc-icon { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; background: #f1f5f9; }

/* ── Progress bar ── */
.progress-bar-wrap { background: #e2e8f0; border-radius: 99px; height: 6px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 99px; background: var(--color-primary); transition: width 0.4s; }

/* ── Breadcrumb ── */
.breadcrumb { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--color-muted); margin-bottom: 1.25rem; }
.breadcrumb a { color: var(--color-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb i { font-size: 0.75rem; }

/* ── Login page ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo i { font-size: 3rem; color: var(--color-primary); }
.login-logo h1 { font-size: 1.5rem; font-weight: 800; margin-top: 0.5rem; }
.login-logo p { color: var(--color-muted); font-size: 0.875rem; }

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }
.sidebar-overlay.show { display: block; }

/* ── Responsive ── */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}
