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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-width: 260px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    text-decoration: none;
}

.logo-icon {
    width: 32px; height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.logo-icon.large { width: 48px; height: 48px; font-size: 24px; border-radius: 12px; }

.sidebar-nav { padding: 12px 8px; flex: 1; overflow-y: auto; }

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

.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item.active { background: #eef2ff; color: var(--primary); }

.sidebar-projects { padding: 0 8px 12px; }
.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.nav-project {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
}

.nav-project:hover { background: var(--bg); text-decoration: none; }

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

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius);
}

.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.logout-btn {
    color: var(--text-muted);
    padding: 6px;
    border-radius: 6px;
    display: flex;
}

.logout-btn:hover { background: #fee2e2; color: #dc2626; }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    max-width: 1400px;
}

/* Avatar */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.avatar.small { width: 28px; height: 28px; font-size: 11px; }
.avatar.tiny { width: 22px; height: 22px; font-size: 9px; }

/* Page header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}

.page-header h1 { font-size: 26px; font-weight: 700; }
.text-muted { color: var(--text-muted); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

.link { color: var(--primary); font-size: 13px; font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

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

.card-header h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 16px 20px; }
.mt-4 { margin-top: 24px; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-value { display: block; font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { display: block; font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 2px; }
.task-list.full .task-item { padding: 14px 20px; }

.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: background .15s;
}

.task-item:hover { background: var(--bg); text-decoration: none; }

.task-check {
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
}

.task-check.status-done { background: #22c55e; border-color: #22c55e; }
.task-check.status-in_progress { border-color: #3b82f6; }
.task-check.status-review { border-color: #f59e0b; }

.task-content { flex: 1; min-width: 0; }
.task-title { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Badges */
.priority-badge, .status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.priority-low { background: #f1f5f9; color: #64748b; }
.priority-medium { background: #dbeafe; color: #2563eb; }
.priority-high { background: #fef3c7; color: #d97706; }
.priority-urgent { background: #fee2e2; color: #dc2626; }

.status-todo { background: #f1f5f9; color: #64748b; }
.status-in_progress { background: #dbeafe; color: #2563eb; }
.status-review { background: #fef3c7; color: #d97706; }
.status-done { background: #d1fae5; color: #059669; }

.due-date { font-size: 12px; color: var(--text-muted); }
.due-date.overdue { color: #dc2626; font-weight: 600; }

.project-badge { font-size: 12px; font-weight: 500; }

.project-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.project-dot.large { width: 12px; height: 12px; }

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

.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    color: var(--text);
    transition: all .15s;
    display: block;
}

.project-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }

.project-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-left: 12px;
    border-left: 3px solid;
}

.project-card-header h3 { font-size: 16px; font-weight: 600; }
.project-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5; }

.project-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

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

.project-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
}

.project-item:hover { background: var(--bg); text-decoration: none; }
.project-info { flex: 1; }
.project-name { display: block; font-weight: 500; font-size: 13px; }
.project-tasks { font-size: 11px; color: var(--text-muted); }

.progress-bar {
    width: 60px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar.small { width: 80px; }
.progress-fill { height: 100%; border-radius: 2px; transition: width .3s; }

/* Project page */
.project-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    gap: 16px;
}

.project-header-info { display: flex; align-items: flex-start; gap: 14px; }
.project-header-info h1 { font-size: 22px; font-weight: 700; }

.project-header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.view-toggle {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 3px;
    border: 1px solid var(--border);
}

.view-toggle a {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
}

.view-toggle a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.members-bar { display: flex; gap: 4px; margin-bottom: 20px; padding-left: 4px; }

/* Kanban */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    align-items: start;
    min-height: 500px;
}

.kanban-column {
    background: var(--bg);
    border-radius: 12px;
    padding: 12px;
    min-height: 200px;
}

.kanban-column.drag-over { background: #eef2ff; }

.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 4px;
}

.column-dot { width: 8px; height: 8px; border-radius: 50%; }
.kanban-column-header h3 { font-size: 13px; font-weight: 600; flex: 1; }
.column-count {
    background: var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
}

.kanban-tasks { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }

.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all .15s;
    box-shadow: var(--shadow);
}

.kanban-card:hover { box-shadow: var(--shadow-lg); }
.kanban-card.dragging { opacity: .5; transform: rotate(2deg); }

.kanban-card-title { font-weight: 500; font-size: 13px; margin-bottom: 8px; line-height: 1.4; }

.kanban-card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.kanban-add-task {
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
}

.kanban-add-task:hover { border-color: var(--primary); color: var(--primary); background: #eef2ff; }

/* List view */
.list-view { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

.task-table { width: 100%; border-collapse: collapse; }
.task-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.task-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.task-table tr.clickable { cursor: pointer; }
.task-table tr.clickable:hover { background: var(--bg); }
.task-table tr:last-child td { border-bottom: none; }

.assignee-cell { display: flex; align-items: center; gap: 8px; }

/* Task detail */
.task-detail { display: grid; grid-template-columns: 1fr 280px; gap: 24px; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.task-title-input {
    font-size: 22px;
    font-weight: 700;
    border: none;
    outline: none;
    width: 100%;
    padding: 8px 0;
    font-family: inherit;
    color: var(--text);
    border-bottom: 2px solid transparent;
    transition: border-color .15s;
}

.task-title-input:focus { border-bottom-color: var(--primary); }

.task-fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 20px 0;
}

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.task-detail-sidebar { display: flex; flex-direction: column; gap: 16px; }

.sidebar-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.sidebar-card h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 12px; }

.detail-item { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.detail-item:last-child { margin-bottom: 0; }
.detail-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* Comments */
.comments-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.comments-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.comment-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.comment-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.comment-form input:focus { border-color: var(--primary); }

.comments-list { display: flex; flex-direction: column; gap: 16px; }

.comment-item { display: flex; gap: 10px; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-header strong { font-size: 13px; }
.comment-body p { font-size: 14px; line-height: 1.5; }

/* Activity */
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.activity-content { flex: 1; }
.activity-content a { font-weight: 500; color: var(--text); text-decoration: none; }
.activity-content a:hover { color: var(--primary); }

/* Filter tabs */
.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    width: fit-content;
}

.filter-tabs a {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
}

.filter-tabs a.active { background: var(--primary); color: white; }
.filter-tabs a:hover:not(.active) { background: var(--bg); text-decoration: none; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }

.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }

.color-option input { display: none; }
.color-option span {
    display: block;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform .15s;
    border: 2px solid transparent;
}

.color-option input:checked + span { transform: scale(1.2); border-color: var(--text); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.open { display: flex; }

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

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    margin: 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 { font-size: 18px; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 4px;
}

.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* Members */
.members-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius);
}

.member-info { flex: 1; }
.member-name { display: block; font-weight: 500; font-size: 14px; }
.member-role { font-size: 12px; color: var(--text-muted); }

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Auth pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container { width: 100%; max-width: 420px; padding: 20px; }

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.auth-header { text-align: center; margin-bottom: 28px; }
.auth-header h1 { font-size: 24px; font-weight: 700; margin: 12px 0 6px; }
.auth-header p { color: var(--text-muted); }

.auth-form { margin-bottom: 16px; }
.auth-footer { text-align: center; font-size: 14px; color: var(--text-muted); }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #059669; border: 1px solid #a7f3d0; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.empty-state.small { padding: 30px 20px; background: transparent; border: none; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 20px; }

/* Labels */
.labels-list { display: flex; flex-wrap: wrap; gap: 6px; }
.label-tag { font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 20px; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    z-index: 9999;
    animation: slideIn .3s ease;
    box-shadow: var(--shadow-lg);
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .kanban-board { grid-template-columns: repeat(2, 1fr); }
    .task-detail { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .kanban-board { grid-template-columns: 1fr; }
    .project-header { flex-direction: column; }
    .task-fields { grid-template-columns: 1fr; }
}
