/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0f1117;
    color: #e2e8f0;
    min-height: 100vh;
    display: flex;
}

/* ===== CSS VARIABLES ===== */
:root {
    --bg:         #0f1117;
    --bg-2:       #161b27;
    --bg-3:       #1e2535;
    --bg-4:       #252d3d;
    --border:     #2a3347;
    --border-2:   #3a4560;
    --text:       #e2e8f0;
    --text-2:     #94a3b8;
    --text-3:     #64748b;
    --accent:     #6366f1;
    --accent-h:   #4f46e5;
    --success:    #10b981;
    --warning:    #f59e0b;
    --danger:     #ef4444;
    --radius:     10px;
    --radius-sm:  6px;
    --shadow:     0 4px 24px rgba(0,0,0,0.4);
    --sidebar-w:  220px;
    --transition: all 0.2s ease;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.sidebar-logo .material-icons { color: var(--accent); font-size: 1.5rem; }
.sidebar-nav { flex: 1; padding: 12px 10px; 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);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,0.15); color: var(--accent); }
.nav-item .material-icons { font-size: 1.1rem; }
.badge {
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    margin-left: auto;
}
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-2);
}
.sidebar-footer .material-icons:first-child { color: var(--text-3); }
.sidebar-footer span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer a { color: var(--text-3); transition: var(--transition); }
.sidebar-footer a:hover { color: var(--danger); }

/* ===== MAIN ===== */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h2 { font-size: 1.25rem; font-weight: 700; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.back-link { color: var(--text-2); transition: var(--transition); display: flex; }
.back-link:hover { color: var(--accent); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn .material-icons { font-size: 1rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-outline { background: transparent; color: var(--text-2); border: 1px solid var(--border-2); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.icon-btn.danger:hover { background: rgba(239,68,68,0.15); color: var(--danger); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn .material-icons { font-size: 1rem; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 10px 12px;
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { margin-bottom: 0; }
.flex-1 { flex: 1; }
.w200 { width: 200px; }
.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}
.input-icon > .material-icons {
    position: absolute;
    left: 10px;
    color: var(--text-3);
    font-size: 1rem;
    pointer-events: none;
    z-index: 2;
}
.input-icon input,
.input-icon .pw-wrap input {
    padding-left: 36px;
    width: 100%;
}
.input-icon .pw-wrap {
    flex: 1;
}

/* Password show/hide toggle */
.pw-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.pw-wrap input {
    width: 100%;
    padding-right: 40px !important;
}
.pw-eye {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    width: 22px;
    height: 22px;
    z-index: 10;
}
.pw-eye:hover { color: var(--accent); }
.pw-eye:hover .material-icons { text-shadow: 0 0 8px rgba(99,102,241,0.6); }
.pw-eye .material-icons { font-size: 1.15rem; pointer-events: none; color: inherit; transition: var(--transition); }

/* ===== AUTH ===== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.auth-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}
.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}
.auth-logo .material-icons { font-size: 2.5rem; color: var(--accent); }
.auth-logo h1 { font-size: 1.5rem; font-weight: 800; margin-top: 8px; }
.auth-logo p { color: var(--text-2); font-size: 0.9rem; margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; }
.auth-switch { text-align: center; font-size: 0.875rem; color: var(--text-2); margin-top: 18px; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ===== ALERTS ===== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
    font-weight: 500;
}
.alert-error  { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.alert-success { background: rgba(16,185,129,0.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }

/* ===== PROJECTS GRID ===== */
.main > .projects-grid,
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
    padding: 24px 28px;
}
.project-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}
.project-card:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.project-card-top { padding: 18px 18px 14px; flex: 1; }
.project-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.project-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.project-card-header h3 { font-size: 1rem; font-weight: 700; flex: 1; }
.project-actions { display: flex; gap: 4px; opacity: 0; transition: var(--transition); }
.project-card:hover .project-actions { opacity: 1; }
.project-desc { font-size: 0.85rem; color: var(--text-2); line-height: 1.5; margin-top: 4px; }
.project-card-footer {
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.progress-wrap { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.progress-bar { height: 5px; background: var(--bg-4); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.5s ease; }
.progress-wrap span { font-size: 0.75rem; color: var(--text-3); }

/* ===== COLOR PICKER ===== */
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch input { display: none; }
.color-swatch span {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
}
.color-swatch input:checked + span { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

/* ===== EMPTY STATES ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 80px 24px;
    color: var(--text-3);
    text-align: center;
}
.empty-state .material-icons { font-size: 3rem; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-2); }
.empty-state p { font-size: 0.875rem; }

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 2px;
    padding: 14px 24px 0;
    border-bottom: 1px solid var(--border);
}
.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    margin-bottom: -1px;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .material-icons { font-size: 1rem; }
.tab-count {
    background: var(--bg-3);
    color: var(--text-3);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
}
.tab-content { display: none; flex: 1; }
.tab-content.active { display: block; }

/* ===== KANBAN ===== */
.kanban-board {
    display: flex;
    gap: 14px;
    padding: 20px 24px;
    overflow-x: auto;
    align-items: flex-start;
    min-height: calc(100vh - 200px);
}
.kanban-col {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 280px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 220px);
}
.col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.col-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); }
.col-count {
    background: var(--bg-3);
    color: var(--text-3);
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.col-todo       .col-title { color: var(--text-2); }
.col-inprogress .col-title { color: #60a5fa; }
.col-inreview   .col-title { color: #a78bfa; }
.col-blocked    .col-title { color: var(--danger); }
.col-done       .col-title { color: var(--success); }

.col-tasks {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
}

/* ===== TASK CARDS ===== */
.task-card {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    transition: var(--transition);
}
.task-card:hover { border-color: var(--border-2); }
.task-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
}
.task-title { font-size: 0.875rem; font-weight: 600; line-height: 1.4; flex: 1; }
.task-card-actions { display: flex; gap: 2px; opacity: 0; transition: var(--transition); flex-shrink: 0; }
.task-card:hover .task-card-actions { opacity: 1; }
.task-desc { font-size: 0.8rem; color: var(--text-2); line-height: 1.5; margin-bottom: 8px; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 8px; }
.task-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-3);
    margin-bottom: 8px;
}
.assignee, .due-date { display: flex; align-items: center; gap: 3px; }
.assignee .material-icons, .due-date .material-icons { font-size: 0.85rem; }
.due-date.overdue { color: var(--danger); }

/* Move buttons */
.task-move {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}
.move-btn {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: var(--transition);
}
.move-btn:hover { background: var(--bg-4); color: var(--text); border-color: var(--border-2); }

/* ===== PRIORITY BADGES ===== */
.priority-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.priority-low    { background: rgba(100,116,139,0.2); color: #94a3b8; }
.priority-medium { background: rgba(59,130,246,0.15); color: #60a5fa; }
.priority-high   { background: rgba(245,158,11,0.15); color: #fbbf24; }
.priority-urgent { background: rgba(239,68,68,0.15);  color: #f87171; }

/* ===== LABELS ===== */
.label-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
}
.label-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.label-check { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.label-check input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

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

/* ===== FILES ===== */
.files-section { padding: 20px 24px; }
.upload-zone {
    border: 2px dashed var(--border-2);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    color: var(--text-3);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 20px;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(99,102,241,0.05);
    color: var(--text);
}
.upload-zone .material-icons { font-size: 2rem; display: block; margin-bottom: 8px; }
.upload-zone p { font-size: 0.875rem; }
.upload-link { color: var(--accent); cursor: pointer; font-weight: 600; }
.upload-bar  { height: 4px; background: var(--bg-3); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.upload-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s ease; width: 0; }
#upload-status { font-size: 0.8rem; color: var(--text-2); display: block; margin-top: 6px; }

.files-list { display: flex; flex-direction: column; gap: 6px; }
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.file-item:hover { border-color: var(--border-2); }
.file-icon { color: var(--accent); font-size: 1.4rem; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.875rem; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 0.75rem; color: var(--text-3); display: block; margin-top: 2px; }
.file-actions { display: flex; gap: 4px; }
.empty-files { text-align: center; padding: 40px; color: var(--text-3); }
.empty-files .material-icons { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ===== ACTIVITY ===== */
.activity-list { padding: 20px 24px; display: flex; flex-direction: column; gap: 2px; }
.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.activity-item:hover { background: var(--bg-2); }
.activity-icon { color: var(--text-3); font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.activity-body { font-size: 0.875rem; line-height: 1.5; }
.activity-time { color: var(--text-3); font-size: 0.75rem; margin-left: 8px; }
.empty-activity { text-align: center; padding: 60px; color: var(--text-3); }
.empty-activity .material-icons { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ===== MODALS ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: slideIn 0.2s ease;
}
.modal-lg { max-width: 640px; }
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 0;
    margin-bottom: 16px;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal form { padding: 0 20px 4px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px 20px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* ===== NOTIFICATIONS PAGE ===== */
.notifications-list { padding: 20px 28px; max-width: 700px; display: flex; flex-direction: column; gap: 6px; }
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.notif-item.unread { border-left: 3px solid var(--accent); background: rgba(99,102,241,0.06); }
.notif-icon { color: var(--accent); font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.notif-body { flex: 1; font-size: 0.875rem; line-height: 1.5; }
.notif-time { font-size: 0.75rem; color: var(--text-3); display: block; margin-top: 3px; }
.notif-actions { display: flex; gap: 4px; }

/* ===== PROFILE PAGE ===== */
.profile-section { padding: 24px 28px; max-width: 500px; }
.profile-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.profile-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 18px; color: var(--text-2); }
.telegram-info {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-2);
}
.telegram-info code {
    background: var(--bg-4);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--accent);
    font-family: monospace;
}
.telegram-connected {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--success);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 10px;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    box-shadow: var(--shadow);
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 999;
    max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: var(--danger); color: #fca5a5; }
.toast.success { border-color: var(--success); color: #6ee7b7; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: var(--transition); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .kanban-board { padding: 12px; gap: 10px; }
    .kanban-col { min-width: 260px; }
    .projects-grid { grid-template-columns: 1fr; padding: 14px; }
    .form-row { flex-direction: column; }
    .topbar { padding: 14px 16px; }
}
