/* CSS Variables with fallbacks for older browsers */
:root {
    --bg-color: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.95);
    --card-bg: rgba(51, 65, 85, 0.6);
    --card-hover: rgba(51, 65, 85, 0.8);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(148, 163, 184, 0.1);
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.light-mode {
    --bg-color: #f1f5f9;
    --sidebar-bg: rgba(255, 255, 255, 0.8);
    --card-bg: #ffffff;
    --card-hover: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --border: rgba(148, 163, 184, 0.2);
    --glass-border: 1px solid rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

body.light-mode .column {
    background: rgba(226, 232, 240, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-mode .modal-content {
    background: #ffffff;
}

body.light-mode input,
body.light-mode textarea,
body.light-mode select {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: var(--text-primary);
}

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

/* Disable double-tap zoom on mobile */
html,
body {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

* {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
}

.app-container {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100%;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 305px;
    background: rgba(30, 41, 59, 0.95);
    /* Solid fallback */
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-right: var(--glass-border);
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    padding: 1.5rem;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: #6366f1;
    color: var(--primary);
    margin-bottom: 2.5rem;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
}

.brand>* {
    margin-right: 0.75rem;
}

.brand>*:last-child {
    margin-right: 0;
}

.projects-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.project-list {
    list-style: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    min-height: 0;
    /* Fallback visibility */
    visibility: visible !important;
    opacity: 1 !important;
}

.project-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    color: #94a3b8;
    /* Fallback color */
    color: var(--text-secondary);
    /* Ensure visibility */
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

.project-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #f8fafc;
    color: var(--text-primary);
}

.project-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
    color: var(--primary);
    font-weight: 500;
}

.project-item-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.project-item-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.project-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-deadline {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding-left: 1.5rem;
    opacity: 0.8;
}

.project-deadline i {
    font-size: 0.7rem;
}

.project-deadline.soon {
    color: var(--warning);
}

.project-deadline.overdue {
    color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.top-bar {
    padding: 2rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.project-info h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #cbd5e1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.project-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.project-title-row h1 {
    margin-bottom: 0;
}

/* Edit-project pencil — mirrors the task-card edit icon (subtle, hover to primary) */
.edit-project-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem;
    font-size: 1.05rem;
    line-height: 1;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.edit-project-btn:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
}

/* ===== Project access control (admin panel — organized by project) ===== */
.project-access-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.access-empty,
.access-col-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.35rem 0.1rem;
}

.access-project-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--card-bg);
}

.access-project-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

.access-project-header:hover {
    background: rgba(99, 102, 241, 0.06);
}

.access-project-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.access-chevron {
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.access-project-header.open .access-chevron {
    transform: rotate(90deg);
}

.access-project-name {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.access-project-count {
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
}

.access-project-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 0 1.25rem 1.25rem;
}

.access-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.access-col-head {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--border);
}

.access-col-head.has {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.35);
}

.access-col-head.no {
    color: var(--text-secondary);
}

.access-member-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: 10px;
    background: var(--bg-color);
}

.access-member-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    overflow: hidden;
}

.access-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.access-member-info {
    flex: 1;
    min-width: 0;
}

.access-member-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.access-member-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.access-add-btn,
.access-remove-btn {
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.access-add-btn {
    background: rgba(99, 102, 241, 0.14);
    color: var(--primary);
}

.access-add-btn:hover {
    background: var(--primary);
    color: #fff;
}

.access-remove-btn {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.access-remove-btn:hover {
    background: var(--danger);
    color: #fff;
}

.access-full-badge {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--success);
    background: rgba(16, 185, 129, 0.14);
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
}

@media (max-width: 640px) {
    .access-project-body {
        grid-template-columns: 1fr;
    }
}

body.light-mode .project-info h1 {
    background: linear-gradient(to right, #0f172a, #475569);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#add-project-btn {
    font-size: 1.1rem;
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    margin-left: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

#add-project-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.project-info p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 600px;
}

.actions {
    display: flex;
    gap: 1rem;
}

.primary-btn,
.secondary-btn,
.danger-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-family);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.primary-btn {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.secondary-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.danger-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Board */
.board-container {
    flex: 1;
    padding: 0 2.5rem 2rem;
    display: none;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
    /* Hidden by default until project selected */
}

.board-container.active {
    display: flex;
}

/* Active workflow: all three working states stay visible together. */
.kanban-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    align-items: stretch;
}

.board-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.4rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--sidebar-bg);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.board-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.board-tab:hover {
    border-color: rgba(148, 163, 184, 0.18);
    color: var(--text);
}

.board-tab:active {
    transform: scale(0.98);
}

/* Assigned tab - purple (default) */
.board-tab[data-view="assigned"] {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.4);
    color: var(--text);
}

.board-tab[data-view="assigned"]:hover {
    background: rgba(99, 102, 241, 0.35);
}

.board-tab[data-view="assigned"].active {
    background: rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.6);
}

.board-tab[data-view="assigned"] .board-tab-count {
    color: #1e293b;
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.25);
}

/* In Progress tab - orange */
.board-tab[data-view="in-progress"] {
    background: rgba(249, 115, 22, 0.25);
    border-color: rgba(249, 115, 22, 0.4);
    color: var(--text);
}

.board-tab[data-view="in-progress"]:hover {
    background: rgba(249, 115, 22, 0.35);
}

.board-tab[data-view="in-progress"].active {
    background: rgba(249, 115, 22, 0.4);
    border-color: rgba(249, 115, 22, 0.6);
}

.board-tab[data-view="in-progress"] .board-tab-count {
    color: #1e293b;
    border-color: rgba(249, 115, 22, 0.4);
    background: rgba(249, 115, 22, 0.25);
}

/* Review tab - yellow */
.board-tab[data-view="review"] {
    background: rgba(234, 179, 8, 0.25);
    border-color: rgba(234, 179, 8, 0.4);
    color: var(--text);
}

.board-tab[data-view="review"]:hover {
    background: rgba(234, 179, 8, 0.35);
}

.board-tab[data-view="review"].active {
    background: rgba(234, 179, 8, 0.4);
    border-color: rgba(234, 179, 8, 0.6);
}

.board-tab[data-view="review"] .board-tab-count {
    color: #1e293b;
    border-color: rgba(234, 179, 8, 0.4);
    background: rgba(234, 179, 8, 0.25);
}

/* Done tab - green */
.board-tab[data-view="done"] {
    background: rgba(34, 197, 94, 0.25);
    border-color: rgba(34, 197, 94, 0.4);
    color: var(--text);
}

.board-tab[data-view="done"]:hover {
    background: rgba(34, 197, 94, 0.35);
}

.board-tab[data-view="done"].active {
    background: rgba(34, 197, 94, 0.4);
    border-color: rgba(34, 197, 94, 0.6);
}

.board-tab[data-view="done"] .board-tab-count {
    color: #1e293b;
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.25);
}

.board-tab-label {
    font-weight: 700;
    font-size: 0.9rem;
}

.board-tab-count {
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid var(--border);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 700;
}

/* Category picker shown only on mobile (via mobile-additions.css) */
#category-picker {
    display: none;
}


.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    gap: 1rem;
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.2;
}

.column {
    background: rgba(15, 23, 42, 0.3);
    border-radius: 16px;
    padding: 0;
    display: none;
    flex-direction: column;
    border: var(--glass-border);
    min-height: 0;
    min-width: 0;
    flex: 1;
    overflow: hidden;
    container-type: inline-size;
}

.column.active {
    display: flex;
}

.column-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.column-header.col-assigned {
    color: #818cf8;
    background: rgba(99, 102, 241, 0.12);
}

.column-header.col-in-progress {
    color: #fb923c;
    background: rgba(249, 115, 22, 0.12);
}

.column-header.col-review {
    color: #facc15;
    background: rgba(234, 179, 8, 0.12);
}

/* Light theme: all workflow headers use the same visual weight. Each status
   keeps its own color, while the main Kanban and «Мои задачи» stay in sync. */
body.light-mode .column-header.col-assigned,
body.light-mode .my-tasks-col-header.col-assigned {
    color: #4338ca;
    background: rgba(99, 102, 241, 0.2);
    border-bottom-color: rgba(67, 56, 202, 0.24);
}

body.light-mode .column-header.col-in-progress,
body.light-mode .my-tasks-col-header.col-in-progress {
    color: #c2410c;
    background: rgba(249, 115, 22, 0.2);
    border-bottom-color: rgba(194, 65, 12, 0.24);
}

body.light-mode .column-header.col-review,
body.light-mode .my-tasks-col-header.col-review {
    color: #92400e;
    background: rgba(250, 204, 21, 0.2);
    border-bottom-color: rgba(180, 83, 9, 0.24);
}

.column-header h2 {
    font-size: 0.9rem;
    font-weight: 700;
    color: currentColor;
    text-transform: none;
    letter-spacing: 0;
    flex: 1;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.todo {
    background: var(--text-secondary);
}

.status-indicator.in-progress {
    background: var(--warning);
}

.status-indicator.review {
    background: #eab308;
}

.status-indicator.done {
    background: var(--success);
}

.count {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.task-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.85rem;
    min-height: 0;
}

.kanban-column-empty {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    padding: 1.5rem 0;
    opacity: 0.7;
}

.kanban-columns .deadline > span,
.task-archive-list .deadline > span {
    font-size: 0.8rem;
}

/* Narrow columns stack their controls instead of letting labels collide. */
@container (max-width: 360px) {
    .column .task-toolbar,
    .task-archive-list .task-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }

    .column .toolbar-right,
    .task-archive-list .toolbar-right {
        justify-content: flex-start;
    }

    .column .task-meta,
    .task-archive-list .task-meta {
        flex-direction: column;
    }

    .column .deadline,
    .task-archive-list .deadline {
        margin-left: 0;
        justify-content: flex-start;
    }

    .column .deadline-tags,
    .task-archive-list .deadline-tags {
        justify-content: flex-start;
    }
}

/* Task Card */
.task-card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: default;
    transition: all 0.2s;
    position: relative;
    backdrop-filter: blur(4px);
    z-index: 1;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    /* Base z-index */
}

/* Ensure card is on top when dropdown is open */
.task-card:has(.status-dropdown.active) {
    z-index: 100 !important;
    transform: translateY(-2px);
    /* Optional visual feedback */
}

/* Fallback for browsers not supporting :has */
.task-card.active-dropdown {
    z-index: 100 !important;
}

/* .task-card:hover {
    background: var(--card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
} */

.task-card.in-progress {
    border: 1px solid rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.1);
}

.task-card.completed {
    opacity: 0.75;
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.task-card.completed .task-title {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.task-title {
    font-weight: 500;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.task-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.65rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 0;
}

.assignee {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex: 1 1 140px;
    min-width: 0;
}

.assignee > span {
    min-width: 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    border: 2px solid var(--card-bg);
    position: relative;
    z-index: 1;
}

.avatar:not(:first-child) {
    z-index: 0;
}

.deadline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
}

.deadline.urgent {
    color: var(--danger);
}

.deadline.deadline-green {
    color: var(--success);
    font-weight: 600;
}

.deadline.deadline-orange {
    color: var(--warning);
    font-weight: 600;
}

.deadline.deadline-red {
    color: var(--danger);
    font-weight: 700;
}

.delete-task,
.edit-task {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-task:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.edit-task:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Task Toolbar - Top row with controls */
.task-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    min-width: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

/* Task Separator Line */
.task-separator {
    height: 1px;
    background: var(--border);
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

/* Old task-actions - no longer used */
.task-actions {
    display: none;
}

.check-btn {
    background: rgba(148, 163, 184, 0.05);
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: default;
    /* Disabled by default */
    font-size: 1.1rem;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    opacity: 0.5;
    /* Default dim state */
}

/* Interactive State (Light/Clickable) */
.check-btn.interactive {
    cursor: pointer;
    border-color: var(--primary);
    /* Or success, depending on preference */
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    opacity: 1;
}

.check-btn.interactive:hover {
    transform: scale(1.1);
    background: rgba(99, 102, 241, 0.2);
}

/* Completed State (Green) */
.check-btn.completed {
    border-color: var(--success) !important;
    background: var(--success) !important;
    color: white !important;
    opacity: 1 !important;
    cursor: pointer;
    /* Keep interactive to uncheck */
    animation: popCheck 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Specific styles for Assignee vs Admin if needed */

@keyframes popCheck {
    0% {
        transform: scale(0.8);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

/* Remove old button style */
.assignee-complete-btn {
    display: none;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #1e293b;
    width: 100%;
    max-width: 500px;
    border-radius: 16px;
    border: var(--glass-border);
    padding: 2rem;
    transform: translateY(20px);
    transition: transform 0.2s;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

.form-row .form-group {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

input,
textarea,
select {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

textarea {
    resize: none;
    overflow-y: auto;
    max-width: 100%;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Dark mode fix for select options */
select option {
    background-color: #1e293b;
    /* Dark background matching sidebar */
    color: #f8fafc;
    /* Light text */
}

body.light-mode select option {
    background-color: #ffffff;
    color: #0f172a;
}

.deadline span {
    font-size: 1.1rem;
    /* Increased font size */
}

.days-left {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-right: 8px;
    font-weight: normal;
}

/* Deadline status tags (can be combined: "На проверке" + "В срок/Просрочено") */
.deadline-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    margin-right: 6px;
    min-width: 0;
}

.deadline-tags-inline {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: 6px;
    vertical-align: middle;
}

.deadline-tag {
    font-size: 0.72rem;
    line-height: 1.1;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: var(--text-secondary);
    background: rgba(148, 163, 184, 0.08);
    font-weight: 700;
    white-space: nowrap;
}

.deadline-tag.tag-review {
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.25);
    background: rgba(99, 102, 241, 0.10);
}

.deadline-tag.tag-ontime {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.25);
    background: rgba(16, 185, 129, 0.10);
}

.deadline-tag.tag-overdue {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.10);
}

.deadline-tag.tag-today {
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.10);
}

.deadline-request-task {
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    padding: .3rem .45rem;
    border-radius: 8px;
    font-size: .95rem;
}
.deadline-request-task:hover { background: rgba(99, 102, 241, .1); }
.deadline-change-form { padding: 1.25rem; }
.deadline-change-current {
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}
.deadline-change-footer { padding: 1rem 0 0; }
.deadline-request-box {
    border: 1px solid rgba(99, 102, 241, .28);
    background: rgba(99, 102, 241, .08);
    border-radius: 14px;
    padding: 1rem;
    display: grid;
    gap: .65rem;
}
.deadline-request-comment { white-space: pre-wrap; color: var(--text-primary); }
.deadline-request-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* Task form body - scrollable on mobile, normal on desktop */
.task-form-body {
    padding: 0;
    /* Desktop doesn't need extra padding */
}

/* Task modal footer - same as regular footer on desktop */
.task-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.private-task-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.06);
    color: var(--text-primary);
    cursor: pointer;
}

.private-task-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.private-task-check {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(148, 163, 184, 0.55);
    border-radius: 7px;
    color: transparent;
    transition: 0.2s ease;
}

.private-task-option input:checked + .private-task-check {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.private-task-option input:focus-visible + .private-task-check {
    outline: 3px solid rgba(99, 102, 241, 0.28);
    outline-offset: 2px;
}

.private-task-option.is-editing {
    cursor: default;
    opacity: 0.78;
}

.private-task-copy {
    display: grid;
    gap: 0.2rem;
}

.private-task-copy strong {
    font-size: 0.92rem;
}

.private-task-copy strong i {
    margin-right: 0.3rem;
    color: var(--primary);
}

.private-task-copy small {
    color: var(--text-secondary);
    line-height: 1.35;
}

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0f1a 0%, #0f172a 40%, #1a1f3a 100%);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
}

.login-overlay::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

/* Legacy login-card for backward compatibility */
.login-card {
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    border: var(--glass-border);
    padding: 2.5rem;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* New Auth Card Design */
.auth-card {
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2rem;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    margin: auto 0;
}

body.light-mode .auth-card {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

/* Единая реакция кнопок: короткий press-state для любого действия и
   встроенный индикатор для операций, которые ждут сеть/Firestore. */
button.button-press-feedback:not(:disabled) {
    filter: brightness(0.9);
    opacity: 0.86;
}

button.is-loading {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    cursor: wait !important;
}

button.is-loading .btn-spinner {
    display: inline-block;
    flex: 0 0 auto;
    width: 1.05em;
    height: 1.05em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: projectman-button-spin 0.72s linear infinite;
}

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

button.is-loading .btn-loading-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.light-mode .login-overlay {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 50%, #f8fafc 100%);
}

/* Auth Logo */
.auth-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    align-self: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
}

.brand-logo-image {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    object-fit: cover;
    border-radius: 7px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
}

.auth-brand {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    width: 100%;
    text-align: center;
    align-self: center;
}

.auth-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 1.25rem;
}

.auth-email-form {
    width: 100%;
    display: grid;
    gap: 0.85rem;
}

.email-verification-panel {
    width: 100%;
    display: grid;
    justify-items: center;
    gap: 0.9rem;
    text-align: center;
}

.email-verification-panel[hidden] {
    display: none;
}

.email-verification-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.14);
    color: #a5b4fc;
    font-size: 1.5rem;
}

.email-verification-panel h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.email-verification-panel p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
}

.email-verification-panel .email-verification-spam-note {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.24);
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    font-weight: 600;
}

.email-verification-spam-note i {
    margin-right: 0.35rem;
}

.email-verification-panel strong {
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.auth-email-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.auth-text-btn {
    border: 0;
    padding: 0.2rem 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 650;
    cursor: pointer;
}

.auth-text-btn:hover {
    color: #a78bfa;
}

.auth-text-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

/* Auth Form */
.auth-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-telegram-widget {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 0;
    min-height: 52px;
}

.auth-provider-list {
    display: grid;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0;
}

.auth-provider-btn,
.auth-link-btn {
    width: 100%;
    height: 50px;
    padding: 0 1.25rem;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
}

.auth-provider-btn:hover,
.auth-link-btn:hover { transform: translateY(-1px); }
.auth-provider-btn:disabled,
.auth-link-btn:disabled { cursor: default; opacity: 0.65; transform: none; }

.auth-provider-btn--google {
    background: #fff;
    color: #172033;
}

.auth-provider-btn--apple {
    background: #000;
    color: #fff;
    border-color: #000;
}

.auth-provider-btn--telegram {
    background: linear-gradient(135deg, #2aabee 0%, #229ed9 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 24px -8px rgba(34, 158, 217, 0.45);
}

.auth-provider-btn--apple .fa-apple,
.auth-link-btn .fa-apple { font-size: 1.25rem; }

.auth-provider-btn__icon {
    width: 1.35rem;
    height: 1.35rem;
    flex: 0 0 1.35rem;
    display: block;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin: 1.15rem 0 0.9rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color, rgba(148, 163, 184, 0.25));
}

.profile-auth-section {
    display: grid;
    gap: 0.8rem;
    padding: 1rem;
    margin: 1rem 0;
    background: var(--surface-secondary, rgba(148, 163, 184, 0.08));
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
    border-radius: 14px;
}

.profile-auth-section h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.profile-auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.profile-auth-current { display: flex; align-items: center; gap: 0.65rem; padding: 0.8rem 0.9rem; border-radius: 12px; background: rgba(99, 102, 241, 0.1); color: var(--text-primary); }
.profile-auth-current > :last-child { margin-left: auto; color: #22c55e; }
.auth-provider-btn__mark--google { color: #4285f4; font-family: Arial, sans-serif; font-weight: 800; }
.auth-link-btn { background: var(--surface, rgba(255,255,255,0.06)); color: var(--text-primary); padding: 0.65rem; }
.auth-link-btn.is-linked { color: #22c55e; }
.profile-auth-status.is-error { color: #ef4444; }
.profile-auth-status.is-success { color: #22c55e; }

@media (max-width: 520px) {
    .profile-auth-actions { grid-template-columns: 1fr; }
}

/* Custom Telegram login button (calls Telegram.Login.auth) */
.telegram-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.9rem 1.5rem;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #2aabee 0%, #229ed9 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 10px 24px -6px rgba(34, 158, 217, 0.55);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.telegram-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px -8px rgba(34, 158, 217, 0.65);
    filter: brightness(1.05);
}

.telegram-login-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 16px -6px rgba(34, 158, 217, 0.5);
}

.telegram-login-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.telegram-login-btn__icon {
    flex-shrink: 0;
}

.telegram-bot-login-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.telegram-bot-login-btn:hover {
    border-color: #229ed9;
    color: #229ed9;
}

.telegram-bot-login-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.auth-form-group[hidden] {
    display: none;
}

.auth-form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    padding-left: 0.25rem;
}

.auth-form-group label i {
    font-size: 0.8rem;
    color: var(--primary);
    width: 16px;
    text-align: center;
}

.auth-form-group input {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 2px solid rgba(148, 163, 184, 0.15);
    background: rgba(15, 23, 42, 0.4);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
    box-sizing: border-box;
}

.auth-form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.auth-form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

body.light-mode .auth-form-group input {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(148, 163, 184, 0.2);
}

body.light-mode .auth-form-group input:focus {
    background: white;
}

/* Auth Form Row (for name fields) */
.auth-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Auth Error */
.auth-error {
    color: #ef4444;
    font-size: 0.85rem;
    text-align: left;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    display: none;
    margin: 0.9rem 0 0;
    width: 100%;
    box-sizing: border-box;
}

.auth-error:not(:empty) {
    display: block;
}

/* Same element doubles as a status line: confirmed-login message is green */
.auth-error.success {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
}

/* Auth Submit Button */
.auth-submit-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    margin-top: 0.15rem;
}

.auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.auth-submit-btn:active {
    transform: translateY(0);
}

/* Auth Cancel Button */
.auth-cancel-btn {
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-cancel-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

/* Auth Buttons Row */
.auth-buttons-row {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    margin-top: 1rem;
}

/* Auth Switch Link */
.auth-switch {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.auth-switch a:hover {
    color: #8b5cf6;
}

/* Mobile Responsive Auth */
@media (max-width: 480px) {
    .login-overlay {
        padding: 1.5rem;
        overflow-y: auto;
        align-items: center;
        justify-content: center;
    }

    .auth-card {
        padding: 1.5rem;
        border-radius: 24px;
        max-width: 400px;
        width: 100%;
        height: auto;
        margin: auto 0;
        justify-content: flex-start;
        box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.18);
        -webkit-overflow-scrolling: touch;
    }

    .auth-logo {
        width: 56px;
        height: 56px;
        margin-bottom: 0.75rem;
    }

    .auth-logo img {
        border-radius: 18px;
    }

    .auth-brand {
        font-size: 1.4rem;
        margin-bottom: 0.8rem;
    }

    .auth-title {
        font-size: 1.25rem;
        margin-bottom: 0.4rem;
    }

    .auth-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.15rem;
    }

    .auth-form {
        gap: 1.5rem;
    }

    .auth-form-row {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .auth-form-group {
        gap: 0.5rem;
    }

    .auth-form-group label {
        font-size: 0.9rem;
        padding-left: 0.1rem;
    }

    .auth-form-group input {
        padding: 0.85rem 1rem;
        font-size: 16px;
        /* Prevents zoom on iOS */
        border-radius: 10px;
    }

    .auth-submit-btn {
        padding: 0.9rem;
        font-size: 1rem;
        margin-top: 0.75rem;
        border-radius: 10px;
    }

    .auth-switch {
        margin-top: 1rem;
        font-size: 0.95rem;
    }

    .auth-email-actions {
        align-items: flex-start;
    }

    .auth-text-btn {
        font-size: 0.82rem;
    }

    .auth-error {
        padding: 0.875rem;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .auth-buttons-row {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

    .auth-cancel-btn {
        width: 100%;
        justify-content: center;
        padding: 1rem;
        border-radius: 10px;
    }
}

/* Legacy Auth Screen Styling */
.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
    width: 100%;
}

.login-card>p {
    text-align: center;
    width: 100%;
}

#auth-screen form {
    width: 100%;
}

#auth-screen .form-group {
    text-align: left;
    width: 100%;
}

#auth-screen .form-group label {
    display: block;
    text-align: left;
}

.login-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-section {
    width: 100%;
    text-align: center;
}

.login-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider span {
    padding: 0 10px;
}

/* Read Only Mode */
body.read-only .primary-btn,
body.read-only .secondary-btn,
body.read-only .danger-btn,
body.read-only .icon-btn,
body.read-only .delete-task {
    display: none !important;
}

/* Exceptions for read-only mode - these buttons should be visible */
body.read-only #help-btn,
body.read-only #theme-toggle,
body.read-only #logout-btn,
body.read-only #mobile-menu-btn,
body.read-only #my-tasks-btn,
body.read-only #agent-notify-btn,
body.read-only #agent-notify-read-all,
body.read-only #agent-notify-delete-all,
body.read-only #agent-chat-btn,
body.read-only #settings-btn,
body.read-only #calendar-btn,
body.read-only #cal-prev-month,
body.read-only #cal-next-month,
body.read-only #cal-today-btn,
body.read-only #submit-completion-btn,
body.read-only #cancel-completion-btn,
body.read-only .close-modal,
body.read-only #org-overlay .primary-btn,
body.read-only #org-overlay .secondary-btn,
body.read-only #org-overlay .org-choice-btn,
body.read-only #auth-overlay .primary-btn,
body.read-only #auth-overlay .secondary-btn,
body.read-only .settings-option,
body.read-only .back-btn,
/* Task interaction for employees */
body.read-only .info-task,
body.read-only .status-badge,
body.read-only .status-dropdown.active,
body.read-only .status-option,
/* Completion proof modal */
body.read-only #completion-proof-modal,
body.read-only #completion-proof-modal .primary-btn,
body.read-only #completion-proof-modal .secondary-btn,
body.read-only #add-completion-file-btn,
body.read-only .remove-attachment-btn,
/* File preview */
body.read-only #preview-download-btn,
body.read-only #files-list-modal .secondary-btn,
body.read-only #file-preview-modal .primary-btn,
/* Project files entry — backend allows any org member (api/project-files) */
body.read-only #project-files-btn,
body.read-only #task-archive-btn,
/* AI agent chat — fully usable by readers (send button + any modal controls) */
body.read-only #agent-chat-modal .primary-btn,
body.read-only #agent-chat-modal .secondary-btn,
body.read-only #agent-chat-send-btn,
/* PIN screen */
body.read-only .pin-key,
body.read-only .pin-keypad button,
/* Task details modal */
body.read-only #task-details-modal,
body.read-only #task-details-modal .secondary-btn,
body.read-only #task-details-modal .task-details-status-btn {
    display: flex !important;
}

/* Force show completion modal buttons */
#submit-completion-btn,
#cancel-completion-btn {
    display: flex !important;
}

body.read-only .task-card {
    cursor: default;
}

body.read-only .task-card:hover {
    transform: none;
    box-shadow: none;
}

/* Enable clicks on status badge for employees */
body.read-only .status-badge {
    pointer-events: auto !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

body.read-only .status-dropdown.active {
    pointer-events: auto !important;
}

body.read-only .status-option {
    pointer-events: auto !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Ensure status elements work on all devices */
.status-badge {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.status-option {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
    /* Apple recommended touch target size */
}

/* Help Modal Styles */
.help-modal-content {
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
}

.help-modal-content .modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    padding: 1.5rem 2rem;
    margin-bottom: 0;
}

.help-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
    padding: 1.5rem 2rem 2rem;
    flex: 1;
}

.help-section {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.help-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.help-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-section p {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-section ul {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.help-section li {
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-section li::before {
    content: '•';
    position: absolute;
    left: 0.5rem;
    color: var(--primary);
    font-weight: bold;
}

.help-note {
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--primary);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* Global AI Agent Chat Modal */
.agent-chat-modal-content {
    max-width: min(940px, 94vw);
    width: 100%;
    max-height: 85vh;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
}

.agent-chat-modal-content .modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    padding: 1.5rem 2rem;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.agent-chat-modal-content .modal-header h2 {
    margin-right: auto;
}

/* Селектор области ответов агента («Все проекты» / конкретный проект) */
.agent-project-select {
    max-width: 200px;
    padding: 0.45rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.agent-project-select:hover,
.agent-project-select:focus {
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .agent-project-select {
        max-width: 130px;
        font-size: 0.8rem;
    }
}

.agent-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 280px;
}

.agent-chat-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    margin: auto 0;
}

/* Clickable example prompts inside the empty chat state: fill the input,
   never auto-submit (see AGENT_CHAT_EXAMPLE_PROMPTS in script.js). */
.agent-chat-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.agent-chat-chip {
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.15s ease;
}

.agent-chat-chip:hover {
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.45);
    background: rgba(99, 102, 241, 0.10);
}

/* Small countdown line above the form while a 429 lockout disables input */
.agent-chat-rate-hint {
    flex-shrink: 0;
    margin: 0.6rem 1.5rem 0;
    font-size: 0.8rem;
    color: var(--warning);
    text-align: center;
}

.agent-chat-rate-hint[hidden] {
    display: none !important;
}

/* «Повторить» on error bubbles: re-submits the failed user message */
.agent-chat-retry-btn {
    display: block;
    margin: 0.45rem auto 0;
    padding: 0.25rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, 0.4);
    background: transparent;
    color: var(--danger);
    font-size: 0.78rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.15s ease;
}

.agent-chat-retry-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.12);
}

.agent-chat-retry-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.agent-chat-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.agent-chat-message-user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.agent-chat-message-assistant {
    align-self: flex-start;
    background: var(--card-bg);
    border: var(--glass-border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.agent-chat-message-error {
    align-self: center;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
}

.agent-chat-message-pending {
    align-self: flex-start;
    background: var(--card-bg);
    border: var(--glass-border);
    color: var(--text-secondary);
    font-style: italic;
}

/* ── Markdown rendering inside the agent's answers ── */
.agent-chat-message-assistant {
    white-space: normal;   /* content is structured DOM, not raw text */
    max-width: 92%;        /* a little wider so tables have room */
}

.agent-md-p { margin: 0 0 0.5rem; }
.agent-md-p:last-child { margin-bottom: 0; }

.agent-md-heading {
    font-weight: 700;
    font-size: 1rem;
    margin: 0.5rem 0 0.35rem;
}

.agent-md-list { margin: 0.25rem 0 0.5rem; padding-left: 1.25rem; }
.agent-md-list li { margin: 0.15rem 0; }

.agent-md-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: rgba(148, 163, 184, 0.18);
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
}

.agent-md-pre {
    margin: 0.4rem 0;
    padding: 0.6rem 0.75rem;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

body:not(.light-mode) .agent-md-pre { background: rgba(0, 0, 0, 0.28); }

.agent-md-pre code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    white-space: pre;
    color: var(--text-primary);
}

.agent-md-table-wrap {
    overflow-x: auto;
    margin: 0.4rem 0;
    -webkit-overflow-scrolling: touch;
}

.agent-md-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85rem;
}

.agent-md-table th,
.agent-md-table td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    text-align: left;
    vertical-align: top;
    white-space: normal;
}

.agent-md-table th {
    background: rgba(99, 102, 241, 0.14);
    font-weight: 700;
}

.agent-md-table tbody tr:nth-child(even) { background: rgba(148, 163, 184, 0.07); }

.agent-chat-form {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}

.agent-chat-attach-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.agent-chat-attach-btn:hover {
    background: rgba(99, 102, 241, 0.10);
    border-color: rgba(99, 102, 241, 0.35);
}

/* ИИ-агент залочен для исполнителей: видна, но не кликабельна */
#agent-chat-btn.agent-btn-locked {
    opacity: 0.45;
    cursor: not-allowed !important;
    filter: grayscale(0.5);
}

#agent-chat-btn.agent-btn-locked:hover {
    background: transparent;
    border-color: var(--border);
    transform: none;
}

.agent-chat-attach-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.agent-chat-file-chip {
    flex-shrink: 0;
    margin: 0.75rem 1.5rem 0;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(99, 102, 241, 0.10);
    color: var(--text-primary);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.agent-chat-file-chip[hidden] {
    display: none !important;
}

.agent-chat-file-chip-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-chat-file-chip-remove {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-chat-input {
    flex: 1;
    resize: none;
    max-height: 120px;
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    line-height: 1.4;
}

.agent-chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.agent-chat-send-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

@media (max-width: 768px) {
    .agent-chat-modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .agent-chat-modal-content .modal-header {
        padding: 1rem 1.25rem;
    }

    .agent-chat-messages {
        padding: 1rem 1.25rem;
    }

    .agent-chat-form {
        padding: 0.75rem 1rem;
    }
}

/* Mobile Responsiveness */
#mobile-menu-btn {
    display: none;
}

@media (max-width: 768px) {
    #mobile-menu-btn {
        display: flex;
        padding: 0.75rem;
        font-size: 1.4rem;
        background: rgba(99, 102, 241, 0.1);
        border-radius: 8px;
        color: var(--primary);
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        width: 85%;
        max-width: 320px;
        z-index: 2000;
        /* Higher z-index to be above everything */
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 25px rgba(0, 0, 0, 0.3);
        background: var(--bg-color);
        /* Ensure solid background */
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        background: rgba(0, 0, 0, 0.6);
        z-index: 1900;
        /* Just below sidebar */
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
        backdrop-filter: blur(4px);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    .board-container {
        display: grid;
        grid-template-columns: 1fr;
        /* Одна колонка на мобильных */
        padding: 0 1rem 2rem;
        gap: 1rem;
        overflow-x: hidden;
        overflow-y: auto;
        /* Вертикальный скролл */
        flex: 1;
        height: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }

    .column {
        min-height: auto;
        max-height: none;
        background: rgba(15, 23, 42, 0.4);
        scroll-snap-align: center;
        /* Центрирование при скролле */
    }

    .task-list {
        max-height: none;
        overflow-y: auto;
        /* Скролл внутри колонки */
        min-height: 100px;
    }

    .top-bar {
        padding: 1rem;
        flex-wrap: wrap;
        align-items: center;
        gap: 1rem;
        background: rgba(15, 23, 42, 0.8);
        backdrop-filter: blur(10px);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .project-info {
        flex: 1;
        min-width: 200px;
    }

    .actions {
        width: 100%;
        gap: 0.75rem;
        margin-top: 0.5rem;
        display: grid;
        grid-template-columns: 1fr auto;
        /* Add task button takes space, help/delete auto */
    }

    #add-task-btn {
        width: 100%;
        justify-content: center;
        padding: 0.875rem;
        font-size: 1rem;
    }

    .actions button {
        min-height: 48px;
        /* Larger touch target */
    }

    #active-project-info h1 {
        font-size: 1.5rem;
    }

    #active-project-info p {
        font-size: 0.9rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
        max-height: 85vh;
        overflow-y: auto;
        margin: 1rem;
    }

    /* Make project items larger for touch */
    .project-item {
        padding: 1rem 1.25rem;
        font-size: 1.05rem;
        min-height: 54px;
        margin-bottom: 0.5rem;
    }

    /* Larger buttons in sidebar */
    .sidebar .primary-btn,
    .sidebar .secondary-btn,
    .sidebar .danger-btn {
        padding: 1rem;
        font-size: 1rem;
        min-height: 50px;
        margin-bottom: 0.75rem;
    }

    /* Make task cards more touch-friendly */
    .task-card {
        padding: 1.25rem;
        margin-bottom: 0.75rem;
        border: 1px solid rgba(255, 255, 255, 0.08);
    }

    .task-title {
        font-size: 1.1rem;
        margin-bottom: 1rem;
        line-height: 1.5;
    }

    .task-meta {
        font-size: 0.9rem;
    }

    /* Delete/Edit buttons on mobile */
    .delete-task,
    .edit-task {
        padding: 0.5rem;
        font-size: 1rem;
    }

    /* Larger form inputs */
    input,
    textarea,
    select {
        padding: 1rem;
        font-size: 1rem;
        min-height: 50px;
    }

    /* Larger modal buttons */
    .modal-footer button {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: 50px;
        flex: 1;
        justify-content: center;
    }

    /* Login card adjustments */
    .login-card {
        width: 100%;
        padding: 1.75rem 1.5rem;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        height: 100%;
        justify-content: center;
    }

    .login-card button {
        min-height: 48px;
        font-size: 1rem;
    }

    .login-card h2 {
        font-size: 1.25rem;
    }

    /* Help modal on mobile */
    .help-modal-content {
        width: 95%;
        max-height: 85vh;
        padding: 0 !important;
        overflow: hidden !important;
    }

    .help-modal-content .modal-header {
        padding: 1rem 1.25rem;
    }

    .help-modal-content .help-content {
        padding: 1rem 1.25rem 1.5rem;
    }

    /* Full viewport height on mobile - optimized for 9:16 format */
    body {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        height: -webkit-fill-available;
        overflow: hidden;
    }

    .app-container {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        height: -webkit-fill-available;
        flex-direction: column;
    }

    .main-content {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        height: -webkit-fill-available;
        width: 100%;
    }

    /* Prevent body scroll on mobile when dragging */
    body.dragging {
        overflow: hidden;
        touch-action: none;
    }

    /* Optimize empty state for mobile */
    .empty-state {
        padding: 2rem 1rem;
        text-align: center;
    }

    .empty-state i {
        font-size: 3rem;
        margin-bottom: 1rem;
    }

    /* Admin Panel on Mobile */
    #admin-panel-modal .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        padding: 0;
    }

    #admin-panel-modal .modal-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: var(--bg-color);
        z-index: 10;
    }

    #admin-panel-modal .admin-panel-content {
        padding: 1rem;
        padding-bottom: 2rem;
    }

    .admin-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
    }

    .admin-tab {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .user-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
    }

    .user-info {
        width: 100%;
    }

    .user-details {
        min-width: 0;
        flex: 1;
    }

    .user-name {
        font-size: 0.95rem;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .user-email {
        font-size: 0.8rem;
        word-break: break-all;
    }

    .user-actions {
        width: 100%;
        justify-content: space-between;
    }

    .role-select {
        flex: 1;
        min-width: 120px;
    }

    /* On mobile, avoid custom select icons in admin users list.
       Some browsers render the SVG caret like repeated "checkmarks". */
    #admin-panel-modal .role-select {
        -webkit-appearance: menulist;
        appearance: menulist;
        background-image: none !important;
        padding-right: 0.75rem;
    }

    .users-list {
        gap: 0.75rem;
    }

    .delete-user-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Admin Panel Styles */
.admin-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.admin-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-tab:hover {
    color: var(--text-primary);
}

.admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

/* Users List */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
}

.user-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.user-item:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.user-role-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-role-badge.admin {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.user-role-badge.reader {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.delete-user-btn {
    padding: 0.5rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.85rem;
    transition: all 0.2s;
}

.delete-user-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
}

/* Project Checkboxes */
.projects-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.project-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.project-checkbox-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.project-checkbox-item input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.project-checkbox-item label {
    margin: 0;
    cursor: pointer;
    color: var(--text-primary);
    flex: 1;
}

/* Multi-select for Assignees */
.multi-select-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    max-height: 150px;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.assignee-option {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    cursor: pointer;
    gap: 0.75rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.assignee-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.assignee-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: auto;
    margin: 0;
    padding: 0;
    cursor: pointer;
}

.assignee-option label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    color: var(--text-primary);
    font-size: 0.9rem;
}

body.light-mode .multi-select-container {
    background: #f8fafc;
    border-color: #e2e8f0;
}

body.light-mode .assignee-option:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Assignee Picker with Search */
.assignee-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selected-assignees {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.selected-assignees:empty {
    display: none;
}

.assignee-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
    padding: 0.35rem 0.5rem 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    animation: chipAppear 0.2s ease;
}

@keyframes chipAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.assignee-chip-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    margin-left: -0.25rem;
}

.assignee-chip-remove {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s;
    padding: 0;
}

.assignee-chip-remove:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.assignee-search-wrapper {
    position: relative;
}

.assignee-search-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.assignee-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.assignee-search-input::placeholder {
    color: var(--text-secondary);
}

.assignee-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.assignee-dropdown.active {
    display: block;
}

.assignee-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.assignee-dropdown-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.assignee-dropdown-item.selected {
    background: rgba(99, 102, 241, 0.15);
}

.assignee-dropdown-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.assignee-dropdown-info {
    flex: 1;
    min-width: 0;
}

.assignee-dropdown-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.assignee-dropdown-email {
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assignee-dropdown-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.assignee-dropdown-check {
    color: var(--primary);
    font-size: 1rem;
}

/* Light mode */

body.light-mode .assignee-chip {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
    border-color: rgba(99, 102, 241, 0.25);
}

body.light-mode .assignee-search-input {
    background: #f8fafc;
    border-color: #e2e8f0;
}

body.light-mode .assignee-dropdown {
    background: white;
    border-color: #e2e8f0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

body.light-mode .assignee-dropdown-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

/* Adjust modal content for admin panel */
#admin-panel-modal .modal-content {
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#admin-panel-modal .admin-panel-content {
    overflow-y: auto;
    flex: 1;
}

/* Task Details Modal - scrollable content */
.task-details-modal-content {
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
}

.task-details-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    margin-bottom: 0;
}

.task-details-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* Mobile adjustments for task details */
@media (max-width: 480px) {
    .task-details-modal-content {
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
    }

    .task-details-header {
        padding: 1.25rem 1.5rem;
    }

    .task-details-body {
        padding: 1.25rem 1.5rem;
    }
}

/* Light mode adjustments */
body.light-mode .user-item {
    background: #f8fafc;
}

body.light-mode .user-item:hover {
    background: rgba(99, 102, 241, 0.05);
}

body.light-mode .projects-checkboxes {
    background: #f8fafc;
}

body.light-mode .project-checkbox-item:hover {
    background: rgba(0, 0, 0, 0.02);
}

/* New Status Badges System — solid, high-contrast chips with distinct colours
   per status. The previous tinted style used two near-identical oranges for
   "назначено" and "в работе", so the status was hard to read at a glance. */
:root {
    --status-assigned: #e67e22;  /* orange */
    --status-in-work: #3b82f6;   /* blue   */
    --status-review: #eab308;     /* yellow */
    --status-done: #16a34a;       /* green  */
}

.status-badge {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    user-select: none;
    border: none;
    color: #fff;
    width: fit-content;
    max-width: 100%;
    white-space: normal;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.status-badge span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.status-dropdown-container {
    min-width: 0;
    max-width: 100%;
}

.status-badge:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.status-badge i {
    color: #fff;
}

.status-assigned {
    background: var(--status-assigned);
    color: #fff;
}

.status-in-work {
    background: var(--status-in-work);
    color: #fff;
}

.status-review {
    background: var(--status-review);
    color: #fff;
}

.status-done {
    background: var(--status-done);
    color: #fff;
}

/* ========== STATUS DROPDOWN ========== */

/* Overlay */
.status-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    -webkit-transition: opacity 0.25s ease, visibility 0.25s ease;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.status-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main dropdown */
.status-dropdown {
    position: fixed;
    z-index: 9999;
    min-width: 220px;
    max-width: 280px;
    background-color: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    -webkit-border-radius: 14px;
    border-radius: 14px;
    padding: 6px;
    -webkit-box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    display: -webkit-flex !important;
    display: flex !important;
    -webkit-flex-direction: column !important;
    flex-direction: column !important;
    -webkit-align-items: stretch !important;
    align-items: stretch !important;
    gap: 4px !important;
    overflow-x: hidden;

    /* Hidden state */
    opacity: 0;
    visibility: hidden;
    -webkit-transform: translateY(-8px);
    -ms-transform: translateY(-8px);
    transform: translateY(-8px);
    -webkit-transition: opacity 0.2s ease, visibility 0.2s ease, -webkit-transform 0.2s ease;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;

    /* Safari fix for rendering */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

body.light-mode .status-dropdown {
    background-color: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
    -webkit-box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Active state */
.status-dropdown.active {
    opacity: 1;
    visibility: visible;
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
}

/* Header */
.status-dropdown-header {
    display: -webkit-flex !important;
    display: flex !important;
    -webkit-align-items: center !important;
    align-items: center !important;
    -webkit-justify-content: center !important;
    justify-content: center !important;
    -webkit-flex: 0 0 auto !important;
    flex: 0 0 auto !important;
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    width: 100%;
}

.status-dropdown-header span {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    display: block;
}

body.light-mode .status-dropdown-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .status-dropdown-header span {
    color: #64748b;
}

/* Status option */
.status-option {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin: 3px 0;
    -webkit-border-radius: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #f8fafc;
    background-color: transparent;
    -webkit-transition: background-color 0.15s ease;
    transition: background-color 0.15s ease;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    -webkit-flex: 0 0 auto !important;
    flex: 0 0 auto !important;
}

body.light-mode .status-option {
    color: #1e293b;
}

.status-option:hover {
    background-color: rgba(99, 102, 241, 0.12);
}

.status-option:active {
    background-color: rgba(99, 102, 241, 0.18);
}

body.light-mode .status-option:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

/* Icon */
.status-option-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    -webkit-border-radius: 8px;
    border-radius: 8px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    font-size: 0.95rem;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

/* Icon colors */
.status-option-icon.work {
    background-color: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.status-option-icon.complete {
    background-color: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.status-option-icon.done {
    background-color: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.status-option-icon.revision {
    background-color: rgba(251, 146, 60, 0.15);
    color: #fb923c;
}

/* Text */
.status-option-text {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
}

.status-option-label {
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-option-desc {
    font-size: 0.7rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.light-mode .status-option-desc {
    color: #64748b;
}

/* ===== MOBILE STYLES ===== */
@media (max-width: 768px) {
    .status-dropdown {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        border-radius: 20px 20px 0 0;
        padding: 8px 12px 28px;
        -webkit-transform: translateY(100%);
        transform: translateY(100%);
    }

    .status-dropdown.active {
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }

    /* Drag handle */
    .status-dropdown::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: 6px auto 12px;
    }

    body.light-mode .status-dropdown::before {
        background: rgba(0, 0, 0, 0.12);
    }

    .status-dropdown-header {
        padding: 6px 12px 12px;
    }

    .status-dropdown-header span {
        font-size: 0.75rem;
    }

    .status-option {
        padding: 14px 16px;
        margin: 4px 0;
        border-radius: 12px;
    }

    .status-option-icon {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        font-size: 1.1rem;
    }

    .status-option-label {
        font-size: 0.95rem;
    }

    .status-option-desc {
        font-size: 0.75rem;
    }
}

/* Override old task actions position - no longer used */
.task-actions {
    display: none;
}

/* Hide old check buttons if any remain */
.check-btn {
    display: none !important;
}

/* Mobile fix for toolbar */
@media (max-width: 768px) {
    .task-toolbar {
        gap: 0.5rem;
    }

    .toolbar-left {
        gap: 0.4rem;
    }

    .status-badge {
        font-size: 0.8rem;
        padding: 4px 8px;
    }

    .task-attachment-badge {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
}

/* ========== FILE ATTACHMENTS ========== */

/* Attachments Container in Task Modal */
.attachments-container {
    background: rgba(15, 23, 42, 0.3);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.attachments-list:empty {
    display: none;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
}

.attachment-item:hover {
    border-color: var(--primary);
}

.attachment-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.attachment-icon.pdf {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.attachment-icon.word {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.attachment-icon.excel {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.attachment-icon.image {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.attachment-icon.archive {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.attachment-icon.other {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-size {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.attachment-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.attachment-remove:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.add-attachment-btn {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.add-attachment-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.add-attachment-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.attachment-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-align: center;
}

/* Uploading State */
.attachment-item.uploading {
    opacity: 0.7;
}

.attachment-item.uploading .attachment-icon {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Attachment Badge on Task Card */
.task-attachment-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.task-attachment-badge:hover {
    background: rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
}

.task-attachment-badge i {
    font-size: 1rem;
}

/* Files Modal List */
.files-modal-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 0;
}

.file-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.file-list-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.file-list-item .attachment-icon {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
}

.file-list-item .attachment-info {
    flex: 1;
}

.file-list-item .attachment-name {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.file-list-item .attachment-size {
    font-size: 0.85rem;
}

.file-delete-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.file-delete-btn:hover {
    color: #fff;
    background: var(--danger, #ef4444);
    border-color: var(--danger, #ef4444);
}

.extraction-status {
    font-weight: 600;
}

.extraction-status-pending {
    color: var(--warning, #f59e0b);
}

.extraction-status-done {
    color: var(--success, #22c55e);
}

.extraction-status-error {
    color: var(--danger, #ef4444);
}

.file-actions .action-btn {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-actions .action-btn:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* File Preview Modal */
.file-preview-content {
    max-width: 90vw;
    max-height: 90vh;
    width: 900px;
}

.file-preview-container {
    width: 100%;
    height: 70vh;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview-container iframe,
.file-preview-container img {
    width: 100%;
    height: 100%;
    border: none;
    object-fit: contain;
}

.file-preview-container .preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.file-preview-container .no-preview {
    text-align: center;
    padding: 2rem;
}

.file-preview-container .no-preview i {
    font-size: 4rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.file-preview-container .no-preview p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Light mode */
body.light-mode .attachments-container {
    background: rgba(241, 245, 249, 0.5);
}

body.light-mode .attachment-item {
    background: #ffffff;
}

body.light-mode .file-list-item {
    background: #ffffff;
}

body.light-mode .file-preview-container {
    background: rgba(0, 0, 0, 0.05);
}

/* ========================================
   MY TASKS BUTTON & MODAL
   ======================================== */

/* My Tasks Button */
.my-tasks-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.my-tasks-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.my-tasks-btn i {
    font-size: 1.1rem;
}

/* Tasks Count Badge */
.my-tasks-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

/* My Tasks Modal */
/* «Мои задачи» — почти полноэкранная мини-доска: три колонки по статусам,
   карточки — те же .task-card, что и на канбан-доске */
.my-tasks-modal-content {
    max-width: min(1500px, 95vw);
    width: 95vw;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.my-tasks-content {
    padding: 1rem 0 0;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.my-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 8px;
    -webkit-overflow-scrolling: touch;
}

/* Режим доски: три колонки на всю высоту модалки */
.my-tasks-list.my-tasks-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.1rem;
    overflow: hidden;
    padding-right: 0;
    align-items: stretch;
}

.my-tasks-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: rgba(148, 163, 184, 0.04);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.my-tasks-col-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
    font-weight: 700;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.my-tasks-col-header.col-assigned {
    color: #818cf8;
    background: rgba(99, 102, 241, 0.12);
}

.my-tasks-col-header.col-in-progress {
    color: #fb923c;
    background: rgba(249, 115, 22, 0.12);
}

.my-tasks-col-header.col-review {
    color: #facc15;
    background: rgba(234, 179, 8, 0.12);
}

.my-tasks-col-count {
    margin-left: auto;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.18);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.my-tasks-col-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    -webkit-overflow-scrolling: touch;
}

.my-tasks-col-empty {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    padding: 1.5rem 0;
    opacity: 0.7;
}

/* Обёртка карточки: чип проекта + настоящая интерактивная канбан-карточка. */
.my-kanban-card-wrap {
    border-radius: 14px;
}

.my-kanban-card-wrap .task-card {
    margin: 0;
}

.my-task-project-chip {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.65rem;
    margin-bottom: 0.35rem;
    border-radius: 9px;
    background: rgba(99, 102, 241, 0.10);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 600;
}

/* Completed tasks archive */
.task-archive-count {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 800;
}

.task-archive-modal-content {
    width: min(1180px, 94vw);
    max-width: 1180px;
    height: min(820px, 88vh);
    max-height: 88vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.task-archive-header {
    margin: 0;
    padding: 1.25rem 1.4rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.11), rgba(16, 185, 129, 0.03));
    flex-shrink: 0;
}

.task-archive-header h2 {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.task-archive-header h2 i {
    color: var(--success);
}

.task-archive-header p {
    margin: 0.3rem 0 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.task-archive-list {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
    align-content: start;
    gap: 1rem;
    scrollbar-gutter: stable;
}

.task-archive-list .task-card {
    margin: 0;
    align-self: start;
    container-type: inline-size;
}

.task-archive-empty {
    grid-column: 1 / -1;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

.task-archive-empty i {
    font-size: 2.25rem;
    color: var(--success);
    opacity: 0.7;
}

/* Action modals opened from «Мои задачи» must stay above the board modal. */
#task-modal.active,
#file-preview-modal.active,
#files-list-modal.active,
#completion-proof-modal.active,
#revision-reason-modal.active,
#deadline-change-modal.active,
#task-details-modal.active {
    z-index: 1100;
}

@media (max-width: 900px) {
    .my-tasks-modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        max-height: 100vh;
        border-radius: 0;
    }

    /* Мобильный: колонки одна под другой, скроллится вся доска */
    .my-tasks-list.my-tasks-board {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        gap: 1rem;
    }

    .my-tasks-col {
        min-height: auto;
        flex-shrink: 0;
    }

    .my-tasks-col-list {
        overflow: visible;
    }

    .task-archive-modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        max-height: 100vh;
        border-radius: 0;
    }

    .task-archive-list {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
}

.my-tasks-list::-webkit-scrollbar {
    width: 6px;
}

.my-tasks-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.my-tasks-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.my-tasks-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Loading state fills the modal body, keeping one clear indicator in its centre. */
.my-tasks-loading {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
}

.my-tasks-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(148, 163, 184, 0.22);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: my-tasks-spin 0.75s linear infinite;
}

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

/* Empty State */
.my-tasks-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.my-tasks-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.my-tasks-empty p {
    font-size: 1rem;
}

/* Task Item in My Tasks Modal */
.my-task-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.my-task-item:hover {
    border-color: var(--primary);
    background: var(--card-hover);
}

.my-task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.my-task-project {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
    flex-shrink: 1;
}

.my-task-project i {
    font-size: 0.75rem;
}

.my-task-status {
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.my-task-status.status-assigned {
    background: rgba(230, 126, 34, 0.15);
    color: #e67e22;
}

.my-task-status.status-in-work {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.my-task-status.status-review,
.my-task-status.status-completed {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.my-task-status.status-done {
    background: rgba(22, 163, 74, 0.15);
    color: #16a34a;
}

.my-task-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
}

.my-task-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    width: 100%;
    min-width: 0;
}

.my-task-meta i {
    margin-right: 0.3rem;
}

.my-task-deadline {
    display: flex;
    align-items: center;
}

.my-task-deadline.overdue {
    color: var(--danger);
}

.my-task-deadline.soon {
    color: var(--warning);
}

/* "Перейти к задаче" — own full-width line so it never collides with the
   deadline/status tags in the narrow modal. */
.my-task-go {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 600;
    margin-top: 0.15rem;
    white-space: nowrap;
}

.my-task-item:hover .my-task-go {
    color: var(--primary);
}


/* Light Mode */
body.light-mode .my-tasks-btn {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: rgba(79, 70, 229, 0.25);
}

body.light-mode .my-tasks-btn:hover {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
}

body.light-mode .my-task-item {
    background: #ffffff;
}

body.light-mode .my-task-item:hover {
    background: #f8fafc;
}

/* Task Card Highlight Animation (when navigating from My Tasks) */
@keyframes highlightTask {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
        transform: scale(1);
    }

    25% {
        box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.4);
        transform: scale(1.01);
    }

    50% {
        box-shadow: 0 0 0 12px rgba(99, 102, 241, 0.2);
        transform: scale(1);
    }

    75% {
        box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.1);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

.task-card.highlight-task {
    animation: highlightTask 2s ease-out;
    border-color: var(--primary) !important;
}

/* ========== TASK DETAILS MODAL ========== */
.task-details-section {
    margin-bottom: 1.5rem;
}

.task-details-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.task-details-section h3 i {
    color: var(--primary);
}

.task-details-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Статус + кнопки жизненного цикла в «Информации о задаче» */
.task-details-status-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.task-details-status-row .status-badge {
    position: static;
    pointer-events: none;
}

.task-details-status-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 10px;
}

.task-details-description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.task-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.timeline-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.timeline-icon.created {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.timeline-icon.in-work {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.timeline-icon.completed {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}

.timeline-icon.archived {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.timeline-content {
    flex: 1;
}

.timeline-label {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.timeline-user {
    font-weight: 400;
    color: var(--primary);
    font-size: 0.9em;
}

.timeline-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.timeline-item.pending {
    opacity: 0.5;
    border-style: dashed;
}

/* Completion Proof Section */
.completion-proof-box {
    background: rgba(46, 204, 113, 0.05);
    border: 1px solid rgba(46, 204, 113, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
    margin-top: 1rem;
}

.completion-proof-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: #2ecc71;
    font-weight: 600;
}

.completion-proof-comment {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.completion-proof-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.completion-proof-file:hover {
    background: rgba(15, 23, 42, 0.7);
}

.completion-proof-file i {
    font-size: 1.5rem;
    color: var(--primary);
}

.completion-proof-file-info {
    flex: 1;
}

.completion-proof-file-name {
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.completion-proof-file-size {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Task Info Button */
.info-task {
    background: #6366f1;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    user-select: none;
    min-height: 30px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.info-task i {
    color: #fff;
}

.info-task:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    filter: brightness(1.05);
}

/* Light mode adjustments */
body.light-mode .task-details-description,
body.light-mode .timeline-item,
body.light-mode .completion-proof-comment,
body.light-mode .completion-proof-file {
    background: #f1f5f9;
}

body.light-mode .completion-proof-box {
    background: rgba(46, 204, 113, 0.08);
}

/* No proof yet indicator */
.no-proof-yet {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.no-proof-yet i {
    font-size: 2rem;
    opacity: 0.3;
    margin-bottom: 0.75rem;
    display: block;
}

/* Revision Reason Section */
.revision-reason-box {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
    padding: 1.25rem;
    margin-top: 1rem;
}

.revision-reason-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: #f59e0b;
    font-weight: 600;
}

.revision-reason-text {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.revision-reason-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.revision-reason-meta span {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

body.light-mode .revision-reason-box {
    background: rgba(245, 158, 11, 0.1);
}

body.light-mode .revision-reason-text {
    background: rgba(0, 0, 0, 0.03);
}

/* ========== SECRET PIN SCREEN ========== */
.pin-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

.pin-container {
    text-align: center;
    padding: 2.5rem;
    max-width: 380px;
    width: 100%;
}

.pin-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
    animation: pinLogoPulse 2s ease-in-out infinite;
}

@keyframes pinLogoPulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 15px 50px rgba(99, 102, 241, 0.6);
    }
}

.pin-logo i {
    font-size: 2.5rem;
    color: white;
}

.pin-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 0.5rem;
}

.pin-subtitle {
    font-size: 1rem;
    color: #94a3b8;
    margin-bottom: 2rem;
}

.pin-dots {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.pin-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.pin-dot.filled {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: #6366f1;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
    transform: scale(1.1);
}

.pin-dot.error {
    background: #ef4444;
    border-color: #ef4444;
    animation: pinShake 0.5s ease;
}

@keyframes pinShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-8px);
    }

    40%,
    80% {
        transform: translateX(8px);
    }
}

.pin-error {
    color: #ef4444;
    font-size: 0.9rem;
    min-height: 1.5rem;
    margin-bottom: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pin-error.visible {
    opacity: 1;
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 280px;
    margin: 0 auto 1.5rem;
}

.pin-key {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
    font-size: 1.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-key:hover:not(.pin-key-empty) {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366f1;
    transform: scale(1.05);
}

.pin-key:active:not(.pin-key-empty) {
    transform: scale(0.95);
    background: rgba(99, 102, 241, 0.4);
}

.pin-key-empty {
    visibility: hidden;
    cursor: default;
}

.pin-key-delete {
    font-size: 1.25rem;
    color: #94a3b8;
}

.pin-key-delete:hover {
    color: #ef4444;
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

.pin-hint {
    color: #64748b;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.pin-hint i {
    color: #6366f1;
}

/* Light mode for PIN screen */
body.light-mode .pin-screen {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #f8fafc 100%);
}

body.light-mode .pin-title {
    color: #1e293b;
}

body.light-mode .pin-subtitle {
    color: #64748b;
}

body.light-mode .pin-dot {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .pin-dot.filled {
    background: linear-gradient(135deg, #3730a3, #4f46e5);
    border-color: #3730a3;
    box-shadow: 0 0 15px rgba(55, 48, 163, 0.4);
}

body.light-mode .pin-key {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

body.light-mode .pin-key:hover:not(.pin-key-empty) {
    background: rgba(99, 102, 241, 0.1);
}

body.light-mode .pin-hint {
    color: #94a3b8;
}

/* ========== Organization Screens ========== */

.org-menu-card {
    width: min(920px, calc(100vw - 2rem));
    max-width: 920px;
}

.org-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

/* Choice buttons */
.org-choice-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 1.25rem;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: var(--text-primary);
}

.org-choice-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.org-choice-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.org-choice-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.org-choice-text strong {
    font-size: 1rem;
    font-weight: 600;
}

.org-choice-text span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.org-choice-btn>i:last-child {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.org-memberships-panel {
    margin-top: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.18);
}

.org-memberships-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(99, 102, 241, 0.05);
}

.org-memberships-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.org-memberships-head p {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.org-refresh-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
}

.org-list-state {
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.org-list-state i {
    color: var(--primary);
}

.org-table-wrap {
    overflow-x: auto;
}

.org-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.org-table th,
.org-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.org-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    font-weight: 700;
    background: rgba(15, 23, 42, 0.12);
}

.org-table tbody tr:last-child td {
    border-bottom: none;
}

.org-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.06);
}

.org-table-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 220px;
}

.org-table-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    flex-shrink: 0;
}

.org-table-title {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.org-table-title strong {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.org-active-label {
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 600;
}

.org-role-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
}

.org-enter-btn {
    min-width: 94px;
    justify-content: center;
    padding: 0.55rem 0.8rem;
}

/* Back button */
.back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

.back-btn:hover {
    color: var(--primary);
}

/* Organization Header in Sidebar */
.org-header {
    position: relative;
    margin-bottom: 1rem;
}

.org-menu-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.org-menu-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

.org-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.org-info i {
    color: var(--primary);
}

.org-chevron {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.org-header.open .org-chevron {
    transform: rotate(180deg);
}

/* Organization Dropdown */
.org-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: hidden;
}

.org-dropdown-header {
    padding: 1rem;
    background: rgba(99, 102, 241, 0.05);
}

.org-dropdown-name {
    font-weight: 600;
    margin: 0 0 0.25rem 0;
}

.org-dropdown-role {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.org-dropdown-divider {
    height: 1px;
    background: var(--border);
}

.org-dropdown-section {
    padding: 1rem;
}

.org-dropdown-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.5rem 0;
}

.org-invite-code-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.org-invite-code-row code {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-family: monospace;
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: var(--primary);
}

.org-copy-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.org-copy-btn:hover {
    background: rgba(99, 102, 241, 0.2);
}

.org-share-btn {
    width: 100%;
    justify-content: center;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.org-regenerate-btn {
    width: 100%;
    justify-content: center;
    font-size: 0.85rem;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.org-regenerate-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

/* My Organizations List */
.my-org-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.my-org-item:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
}

.my-org-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.my-org-info {
    flex: 1;
    min-width: 0;
}

.my-org-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.my-org-role {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.my-org-arrow {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.org-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 0.9rem;
}

.org-dropdown-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.org-dropdown-item i {
    width: 20px;
    color: var(--text-secondary);
}

.org-dropdown-item.org-leave {
    color: var(--danger);
}

.org-dropdown-item.org-leave i {
    color: var(--danger);
}

/* Light mode adjustments */
body.light-mode .org-choice-btn {
    background: rgba(99, 102, 241, 0.05);
    border-color: #e2e8f0;
}

body.light-mode .org-choice-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

body.light-mode .org-memberships-panel {
    background: rgba(248, 250, 252, 0.95);
    border-color: #e2e8f0;
}

body.light-mode .org-memberships-head,
body.light-mode .org-table th {
    background: rgba(99, 102, 241, 0.06);
}

body.light-mode .org-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

body.light-mode .org-menu-btn {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.15);
}

body.light-mode .org-dropdown {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.org-dropdown-header {
    background: rgba(99, 102, 241, 0.1);
}

body.light-mode .org-dropdown-header {
    background: rgba(99, 102, 241, 0.08);
}

body.light-mode .org-invite-code-row code {
    background: #f1f5f9;
}

@media (max-width: 720px) {
    .org-menu-card {
        width: min(100vw - 1rem, 520px);
        max-height: calc(100vh - 1rem);
        overflow-y: auto;
    }

    .org-actions-grid {
        grid-template-columns: 1fr;
    }

    .org-table th,
    .org-table td {
        padding: 0.75rem;
    }
}

/* Role badges */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.role-badge.owner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(251, 191, 36, 0.2));
    color: #f59e0b;
}

.role-badge.admin {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.role-badge.moderator {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.role-badge.employee {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

/* Role select dropdown */
.role-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    /* Use a caret (triangle) */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='%2394a3b8' d='M7,10L12,15L17,10Z'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.5rem center !important;
    background-size: 16px 16px !important;
}

.role-select:focus {
    outline: none;
    border-color: var(--primary);
}

body.light-mode .role-select {
    background-color: #f8fafc;
    border-color: #e2e8f0;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='%230f172a' d='M7,10L12,15L17,10Z'/%3e%3c/svg%3e") !important;
}

/* Delete user button in admin panel */
.delete-user-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.delete-user-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

/* ========== NEW PROJECT MODAL ========== */
.project-modal-content {
    max-width: 420px;
    width: 90%;
    padding: 0;
    border-radius: 20px;
    overflow: hidden;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

body.light-mode .project-modal-content {
    background: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.project-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.project-modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.project-modal-icon {
    width: 72px;
    height: 72px;
    margin: 2rem auto 1rem;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
    box-shadow: 0 10px 40px -10px rgba(99, 102, 241, 0.5);
}

.project-modal-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.project-modal-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.project-modal-form {
    padding: 0 1.75rem 1.75rem;
}

.project-form-group {
    margin-bottom: 1.25rem;
}

.project-form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.project-form-group label i {
    font-size: 0.8rem;
    color: var(--primary);
}

.project-form-group input,
.project-form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: rgba(148, 163, 184, 0.05);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.project-form-group input:focus,
.project-form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.project-form-group input::placeholder,
.project-form-group textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.project-form-group textarea {
    resize: none;
    min-height: 80px;
}

/* Deadline Toggle */
.project-deadline-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.05);
    border: 1px solid var(--border);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.toggle-label i {
    color: var(--primary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(148, 163, 184, 0.3);
    border-radius: 26px;
    transition: all 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(22px);
}

/* Deadline Field */
.project-deadline-field {
    display: none;
    animation: slideDown 0.3s ease;
}

.project-deadline-field.active {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Actions */
.project-modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.project-btn-cancel,
.project-btn-create {
    flex: 1;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    border: none;
}

.project-btn-cancel {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.project-btn-cancel:hover {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-primary);
}

.project-btn-create {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    box-shadow: 0 4px 15px -3px rgba(99, 102, 241, 0.4);
}

.project-btn-create:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px -3px rgba(99, 102, 241, 0.5);
}

.project-btn-create:active {
    transform: translateY(0);
}

/* ========== SETTINGS MODAL ========== */
.settings-modal-content {
    max-width: 760px;
    width: min(760px, 92vw);
    padding: 0;
    border-radius: 20px;
    overflow: hidden;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

body.light-mode .settings-modal-content {
    background: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.settings-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.settings-modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.settings-modal-icon {
    width: 64px;
    height: 64px;
    margin: 2rem auto 1rem;
    border-radius: 16px;
    background: linear-gradient(135deg, #64748b, #475569);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 10px 40px -10px rgba(100, 116, 139, 0.5);
}

.settings-modal-title {
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.settings-options {
    padding: 0 1.5rem 1.75rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.settings-option-wide {
    grid-column: 1 / -1;
}

.settings-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 92px;
    padding: 1.15rem;
    border-radius: 14px;
    background: rgba(148, 163, 184, 0.05);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.settings-option:hover {
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -18px rgba(15, 23, 42, 0.55);
}

.settings-option:disabled,
.settings-option.disabled {
    cursor: not-allowed;
}

.settings-option:disabled:hover,
.settings-option.disabled:hover {
    transform: none;
    box-shadow: none;
}

.settings-option-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.settings-option-icon.admin {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    color: var(--primary);
}

/* Disabled admin panel button for non-admin users */
.settings-option.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.settings-option.disabled .settings-option-icon.admin {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.15), rgba(148, 163, 184, 0.15));
    color: var(--text-secondary);
}

.settings-option.disabled .settings-option-title,
.settings-option.disabled .settings-option-desc {
    color: var(--text-secondary);
}

.settings-option.disabled>i.fa-chevron-right {
    opacity: 0.3;
}

.settings-option-icon.theme {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.2));
    color: #f59e0b;
}

.settings-option-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings-option-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-option-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.settings-option>i.fa-chevron-right {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Theme toggle in settings */
.theme-toggle-switch {
    margin-left: auto;
}

.theme-toggle-switch .toggle-slider {
    background: rgba(148, 163, 184, 0.3);
}

body.light-mode .theme-toggle-switch .toggle-slider {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

body.light-mode .theme-toggle-switch .toggle-slider:before {
    transform: translateX(22px);
}

/* ========== TELEGRAM SETTINGS ========== */
.settings-option-icon.telegram {
    background: linear-gradient(135deg, rgba(0, 136, 204, 0.2), rgba(0, 162, 232, 0.2));
    color: #0088cc;
}

.settings-option-telegram.telegram-connected {
    opacity: 1;
    border-color: rgba(16, 185, 129, 0.28);
    background: rgba(16, 185, 129, 0.06);
}

.settings-option-telegram.telegram-connected .settings-option-icon.telegram {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2));
    color: var(--success);
}

.settings-option-telegram.telegram-connected .settings-option-title {
    color: var(--text-primary);
}

.settings-option-telegram.telegram-connected .settings-option-desc,
.settings-option-telegram.telegram-connected #telegram-link-status-icon {
    color: var(--success);
}

.settings-option-telegram.telegram-link-busy {
    opacity: 0.72;
}

.telegram-steps {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.telegram-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content p {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.telegram-bot-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #0088cc, #00a2e8);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.telegram-bot-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

.telegram-code {
    background: var(--bg-secondary, #1e293b);
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    letter-spacing: 0.3rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.copy-code-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    width: 100%;
}

.copy-code-btn:hover {
    background: var(--card-hover);
    color: var(--text-primary);
}

.copy-code-btn.copied {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: var(--success);
}

/* ========== KEYBOARD NAVIGATION ========== */
body.keyboard-nav .project-item.keyboard-focus,
body.keyboard-nav .task-card.keyboard-focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

body.keyboard-nav .project-item.keyboard-focus {
    background: var(--card-hover);
}

body.keyboard-nav .task-card.keyboard-focus {
    transform: translateY(-2px);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2), var(--shadow);
}

/* Keyboard nav indicator */
.keyboard-nav-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.keyboard-nav-hint.visible {
    opacity: 1;
}

.keyboard-nav-hint kbd {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* ========== PERSONAL PROFILE STYLES ========== */
.settings-option-icon.profile {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2));
    color: var(--success);
}

.settings-option-icon.leaderboard {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.2));
    color: var(--warning);
}

.settings-option-icon.help {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(99, 102, 241, 0.2));
    color: #4f7df3;
}

.profile-modal-content {
    width: min(880px, 92vw);
    max-width: 880px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.profile-content {
    padding: 1.5rem;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(420px, 1.45fr);
    grid-template-areas:
        "header auth"
        "form form"
        "message message"
        "level stats"
        "danger danger";
    align-items: stretch;
    column-gap: 1rem;
    row-gap: 0;
}

.profile-content > .profile-auth-section {
    grid-area: auth;
    margin: 0;
    min-height: 112px;
    align-content: center;
}

.profile-danger-section {
    grid-area: danger;
    margin-top: 1rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid rgba(239, 68, 68, 0.28);
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.07);
}

.profile-danger-section h3,
.profile-danger-section p { margin: 0; }
.profile-danger-section p { margin-top: 0.25rem; color: var(--text-secondary); font-size: 0.84rem; }
.profile-delete-account {
    flex: 0 0 auto;
    border: 1px solid rgba(239, 68, 68, 0.45);
    border-radius: 11px;
    padding: 0.7rem 0.9rem;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    font-weight: 700;
}
.profile-delete-account:disabled { opacity: 0.55; cursor: wait; }

.profile-header {
    grid-area: header;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin: 0;
    min-height: 112px;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.profile-avatar-wrapper {
    position: relative;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    color: white;
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-upload {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid var(--bg-color);
}

.profile-avatar-upload:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.profile-avatar-upload i {
    font-size: 0.75rem;
    color: white;
}

.profile-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.profile-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.profile-name-edit {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.18s ease;
}

.profile-name-edit:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.16);
    transform: translateY(-1px);
}

.profile-name-form {
    grid-area: form;
    margin: 1rem 0 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card-bg);
}

.profile-name-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.profile-name-fields label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
}

.profile-name-fields input {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 0.8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg, var(--bg-color));
    color: var(--text-primary);
    font: inherit;
    font-size: 0.92rem;
    outline: none;
}

.profile-name-fields input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.profile-name-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 0.9rem;
}

.profile-name-actions button {
    min-width: 112px;
}

.profile-name-error,
.profile-name-message {
    margin: 0.7rem 0 0;
    font-size: 0.82rem;
}

.profile-name-error {
    color: var(--danger);
}

.profile-name-message {
    grid-area: message;
    margin: 1rem 0 0;
    color: var(--success);
    font-weight: 600;
}

.profile-level-section {
    grid-area: level;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1rem 0 0;
    text-align: center;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.profile-level-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
}

.level-number {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
}

.level-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.profile-xp-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.xp-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.xp-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.profile-stats {
    grid-area: stats;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.profile-stat {
    background: var(--card-bg);
    border-radius: 12px;
    min-height: 88px;
    padding: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--border);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.stat-icon.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.stat-icon.completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.stat-icon.ontime {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.stat-icon.percent {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ========== LEADERBOARD STYLES ========== */
.leaderboard-modal-content {
    max-width: 500px;
}

.leaderboard-content {
    padding: 1.5rem;
}

.leaderboard-podium {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0;
}

.podium-place {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    text-align: left;
}

.podium-place.gold {
    order: 1;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 184, 0, 0.1));
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.podium-place.silver {
    order: 2;
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(168, 168, 168, 0.1));
    border: 1px solid rgba(192, 192, 192, 0.3);
}

.podium-place.bronze {
    order: 3;
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(184, 114, 45, 0.1));
    border: 1px solid rgba(205, 127, 50, 0.3);
}

.podium-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    position: relative;
    flex-shrink: 0;
}

.podium-place.gold .podium-avatar {
    width: 56px;
    height: 56px;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #ffd700, #ffb800);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.podium-place.silver .podium-avatar {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
    box-shadow: 0 4px 12px rgba(192, 192, 192, 0.4);
}

.podium-place.bronze .podium-avatar {
    background: linear-gradient(135deg, #cd7f32, #b8722d);
    box-shadow: 0 4px 12px rgba(205, 127, 50, 0.4);
}

.podium-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.podium-medal {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    border: 2px solid var(--bg-color);
}

.podium-place.gold .podium-medal {
    background: #ffd700;
    color: #8b6914;
}

.podium-place.silver .podium-medal {
    background: #c0c0c0;
    color: #5a5a5a;
}

.podium-place.bronze .podium-medal {
    background: #cd7f32;
    color: #5a3d1a;
}

.podium-info {
    flex: 1;
    min-width: 0;
}

.podium-place>.podium-name,
.podium-place>.podium-level {
    display: none;
}

.podium-info .podium-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-info .podium-level {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
}

.podium-info .podium-stats {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

.podium-place>.podium-xp {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 0.75rem 1rem;
}

.leaderboard-rank {
    width: 28px;
    height: 28px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.leaderboard-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    overflow: hidden;
}

.leaderboard-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.leaderboard-info {
    flex: 1;
    min-width: 0;
}

.leaderboard-name {
    font-size: 0.9rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-stats {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.leaderboard-xp {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
}

.leaderboard-note {
    text-align: center;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.leaderboard-note i {
    color: var(--primary);
}

.leaderboard-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}



/* Mobile styles for profile and leaderboard */
@media (max-width: 768px) {
    .settings-modal-content {
        width: 92%;
        max-width: 390px;
    }

    .settings-options {
        grid-template-columns: 1fr;
        padding: 0 1.25rem 1.5rem;
        gap: 0.75rem;
    }

    .settings-option {
        min-height: 0;
        padding: 1rem;
    }

    .profile-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .profile-content {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "header"
            "form"
            "message"
            "auth"
            "level"
            "stats"
            "danger";
        align-content: start;
        padding: 1rem;
    }

    .profile-danger-section {
        align-items: stretch;
        flex-direction: column;
    }

    .profile-delete-account {
        width: 100%;
    }

    .profile-header,
    .profile-content > .profile-auth-section {
        min-height: 0;
    }

    .profile-content > .profile-auth-section {
        margin-top: 1rem;
    }

    .profile-name-fields {
        grid-template-columns: 1fr;
    }

    .leaderboard-modal-content {
        width: 92%;
        max-width: 360px;
        height: auto;
        max-height: none;
        margin: auto;
        border-radius: 20px;
        overflow: hidden;
    }

    .leaderboard-content {
        padding: 1rem;
    }

    .podium-place {
        padding: 0.875rem 1rem;
    }

    .podium-avatar {
        width: 46px !important;
        height: 46px !important;
        font-size: 1rem !important;
    }

    .podium-place.gold .podium-avatar {
        width: 50px !important;
        height: 50px !important;
    }

    .podium-info .podium-name {
        font-size: 0.9rem;
    }

    .podium-info .podium-level {
        font-size: 0.75rem;
    }

    .podium-info .podium-stats {
        font-size: 0.7rem;
    }

    .podium-place>.podium-xp {
        font-size: 1rem;
    }

    .profile-stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .profile-stat {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .podium-medal {
        width: 20px;
        height: 20px;
        font-size: 0.65rem;
        bottom: -2px;
        right: -2px;
    }


}

/* Ensure profile and leaderboard buttons visible for all users */
body.read-only #profile-btn,
body.read-only #leaderboard-btn,
body.read-only #profile-modal,
body.read-only #leaderboard-modal {
    display: flex !important;
}

/* Ensure photo crop modal and buttons visible for all users */
body.read-only #crop-modal,
body.read-only #crop-modal .primary-btn,
body.read-only #crop-modal .secondary-btn,
body.read-only #crop-save,
body.read-only #crop-cancel,
body.read-only .crop-footer,
body.read-only .crop-footer button,
body.read-only #profile-modal .primary-btn,
body.read-only #profile-modal .secondary-btn,
body.read-only .profile-avatar-edit,
body.read-only .profile-avatar-upload,
body.read-only #profile-avatar-upload {
    display: flex !important;
}

/* Light mode for profile */
body.light-mode .profile-level-section {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

body.light-mode .profile-stat {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

body.light-mode .profile-xp-bar {
    background: #e2e8f0;
}

body.light-mode .stat-icon.active {
    background: rgba(99, 102, 241, 0.1);
}

body.light-mode .stat-icon.completed {
    background: rgba(16, 185, 129, 0.1);
}

body.light-mode .stat-icon.ontime {
    background: rgba(59, 130, 246, 0.1);
}

body.light-mode .stat-icon.percent {
    background: rgba(245, 158, 11, 0.1);
}

body.light-mode .leaderboard-empty {
    color: var(--text-secondary);
}

/* ========== PHOTO CROP MODAL ========== */
.crop-modal-content {
    max-width: 400px;
    padding: 0;
}

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

.crop-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.crop-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-image {
    max-width: 100%;
    max-height: 100%;
    cursor: move;
    user-select: none;
    -webkit-user-drag: none;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.crop-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
}

.crop-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.crop-footer button {
    min-width: 100px;
}

.crop-zoom {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.crop-zoom label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.crop-zoom input[type="range"] {
    flex: 1;
    min-height: auto;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    height: 4px;
    border-radius: 2px;
    outline: none;
}

.crop-zoom input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* ========== CALENDAR STYLES ========== */
.settings-option-icon.calendar {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: white;
}

/* Calendar view: third workspace view (Канбан / Гант / Календарь),
   styled like the gantt container — in-page, program palette. */
.calendar-view-container {
    flex: 1;
    display: none;
    flex-direction: column;
    padding: 0 2.5rem 2rem;
    min-height: 0;
}

.calendar-view-container.active {
    display: flex;
    animation: calendarViewFadeIn 0.25s ease;
}

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

.calendar-view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.calendar-header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.calendar-view-toolbar h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    min-width: 160px;
    text-align: center;
    text-transform: capitalize;
}

.calendar-view-toolbar .icon-btn {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-view-toolbar .icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.calendar-view-container .calendar-body {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.calendar-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    min-height: 0;
    background: var(--card-bg);
}

.calendar-week-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
}

.calendar-week-days span {
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(var(--calendar-week-count, 6), minmax(0, 1fr));
    gap: 0;
    background: transparent;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    min-height: 0;
}

.calendar-day {
    background: var(--card-bg);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 0;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

.calendar-day:not(.calendar-day-empty) {
    box-shadow: inset 0 0 0 1px var(--border);
}

.calendar-day:hover {
    background: rgba(99, 102, 241, 0.05);
}

.calendar-day.calendar-day-empty {
    background: rgba(15, 23, 42, 0.035);
    box-shadow: none;
    cursor: default;
    pointer-events: none;
}

/* In dark mode the month must read as a grid, not as one flat panel. */
body:not(.light-mode) .calendar-view-container .calendar-body {
    border-color: rgba(148, 163, 184, 0.34);
}

body:not(.light-mode) .calendar-grid {
    background: transparent;
    box-shadow: none;
}

body:not(.light-mode) .calendar-day {
    background: #26344a;
}

body:not(.light-mode) .calendar-day:not(.calendar-day-empty) {
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.30);
}

body:not(.light-mode) .calendar-day:hover {
    background: #30415d;
}

body:not(.light-mode) .calendar-day.calendar-day-empty {
    background: #202c3f;
    box-shadow: none;
}

.calendar-day .day-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 2px;
}

.calendar-day.today .day-number {
    background: #2563eb;
    color: white;
}

.calendar-events-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.calendar-event-pill {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(37, 99, 235, 0.15);
    color: #2563eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid #2563eb;
    font-weight: 600;
}

/* Task pills on the calendar — one flat color per task status so a whole
   month's workload is scannable at a glance. */
.calendar-task-pill {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid currentColor;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
}

.calendar-task-title {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-task-pill .pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.calendar-task-pill.task-assigned  { color: #f59e0b; background: rgba(245, 158, 11, 0.14); }
.calendar-task-pill.task-in_work   { color: #3b82f6; background: rgba(59, 130, 246, 0.14); }
.calendar-task-pill.task-completed { color: #8b5cf6; background: rgba(139, 92, 246, 0.14); }
.calendar-task-pill.task-done      { color: #22c55e; background: rgba(34, 197, 94, 0.14); }
.calendar-task-pill.task-overdue   { color: #ef4444; background: rgba(239, 68, 68, 0.16); }

.calendar-day-more {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 1px 6px;
}

/* Day-tasks modal (opens when a day cell is clicked) */
.day-tasks-modal-content {
    max-width: 560px;
    width: 94%;
    border-radius: 24px;
    overflow: hidden;
    padding: 0 !important;
}

.day-tasks-header {
    background: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.day-tasks-header h2 {
    color: #fff !important;
    font-size: 1.15rem;
    margin: 0;
}

.day-tasks-header .close-modal {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

.day-tasks-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 60vh;
    overflow-y: auto;
}

.day-task-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.2s;
    border-left-width: 4px;
}

.day-task-row:hover {
    border-color: var(--primary);
    transform: translateX(3px);
}

.day-task-row.task-assigned  { border-left-color: #f59e0b; }
.day-task-row.task-in_work   { border-left-color: #3b82f6; }
.day-task-row.task-completed { border-left-color: #8b5cf6; }
.day-task-row.task-done      { border-left-color: #22c55e; }
.day-task-row.task-overdue   { border-left-color: #ef4444; }

.day-task-info { flex: 1; min-width: 0; }

.day-task-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day-task-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day-task-status-tag {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.day-task-status-tag.task-assigned  { color: #f59e0b; background: rgba(245, 158, 11, 0.16); }
.day-task-status-tag.task-in_work   { color: #3b82f6; background: rgba(59, 130, 246, 0.16); }
.day-task-status-tag.task-completed { color: #8b5cf6; background: rgba(139, 92, 246, 0.16); }
.day-task-status-tag.task-done      { color: #22c55e; background: rgba(34, 197, 94, 0.16); }
.day-task-status-tag.task-overdue   { color: #ef4444; background: rgba(239, 68, 68, 0.16); }

.day-tasks-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 1.5rem 0;
}

.day-tasks-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    justify-content: flex-end;
}

/* Event Modal Styling */
.cal-event-modal-content {
    max-width: 520px;
    width: 94%;
    border-radius: 24px;
    overflow: hidden;
    padding: 0 !important;
}

.cal-header {
    background: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
    padding: 1.25rem 1.5rem;
}

.cal-header h2 {
    color: white !important;
    font-size: 1.15rem;
}

.cal-event-form-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.cal-event-footer {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.ce-participants-picker {
    position: relative;
}

.ce-users-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.ce-user-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s;
    color: var(--text);
}

.ce-user-option:hover {
    background: rgba(37, 99, 235, 0.1);
}

.ce-users-dropdown.active {
    display: block;
}

.ce-selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.ce-user-chip {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ce-user-chip i {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.ce-user-chip i:hover {
    opacity: 1;
}

/* Mobile Adaptation for Calendar */
@media (max-width: 768px) {
    .calendar-view-container {
        padding: 0 0.75rem 1rem;
    }

    .calendar-view-toolbar {
        padding: 0.75rem 0;
    }

    .calendar-header-nav {
        gap: 0.5rem;
    }

    .calendar-view-toolbar h2 {
        font-size: 1rem;
        min-width: 110px;
    }

    .calendar-body {
        padding: 0.75rem;
    }

    .calendar-week-days span {
        font-size: 0.65rem;
    }

    .calendar-day {
        padding: 0.25rem;
    }

    .calendar-day .day-number {
        font-size: 0.75rem;
        width: 20px;
        height: 20px;
    }

    .calendar-event-pill {
        font-size: 0.6rem;
        padding: 1px 4px;
        border-width: 2px;
    }

    .calendar-task-pill {
        font-size: 0.6rem;
        padding: 1px 4px;
    }

    .calendar-task-pill .pill-dot {
        width: 5px;
        height: 5px;
    }

    .cal-event-modal-content {
        width: 100% !important;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* ===== Agent notifications feed (колокольчик) ===== */
.agent-notify-modal-content {
    width: min(900px, 94vw);
    max-width: 900px;
    height: min(760px, 86vh);
    max-height: 86vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
}

.agent-notify-header {
    margin: 0;
    padding: 1.25rem 1.4rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.11), rgba(139, 92, 246, 0.04));
}

.agent-notify-heading {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.agent-notify-heading-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}

.agent-notify-heading h2 {
    margin: 0;
    font-size: 1.2rem;
}

.agent-notify-heading p {
    margin: 0.2rem 0 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.agent-notify-content {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem 1.25rem;
}

.agent-notify-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

.agent-notify-read-all,
.agent-notify-delete-all {
    width: auto;
    min-height: 38px;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.45rem 0.85rem;
    border-radius: 11px;
}

.agent-notify-delete-all {
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.35);
}

.agent-notify-delete-all:hover:not(:disabled) {
    color: #b91c1c;
    border-color: rgba(220, 38, 38, 0.65);
    background: rgba(239, 68, 68, 0.10);
}

.agent-notify-read-all:disabled,
.agent-notify-delete-all:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.agent-notify-list {
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.1rem 0.25rem 0.5rem 0.1rem;
    scrollbar-gutter: stable;
}

.agent-notify-item {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    position: relative;
    padding: 0.9rem 3.15rem 0.9rem 0.9rem;
    border-radius: 15px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.agent-notify-item:hover {
    transform: translateY(-1px);
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow: 0 9px 24px rgba(15, 23, 42, 0.10);
}

body.light-mode .agent-notify-item:hover {
    background: #fff;
}

.agent-notify-item.unread {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.13), rgba(99, 102, 241, 0.05));
    border-color: rgba(99, 102, 241, 0.30);
}

.agent-notify-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #818cf8;
    background: rgba(99, 102, 241, 0.13);
    flex-shrink: 0;
}

.agent-notify-item.type-warning .agent-notify-icon {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.13);
}

.agent-notify-item.type-danger .agent-notify-icon {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.13);
}

.agent-notify-item.type-success .agent-notify-icon {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.13);
}

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

.agent-notify-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.28rem;
}

.agent-notify-title {
    font-size: 0.92rem;
    line-height: 1.2;
    font-weight: 750;
    color: var(--text-primary);
}

.agent-notify-unread-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.11);
    flex-shrink: 0;
}

.agent-notify-text {
    font-size: 0.84rem;
    line-height: 1.45;
    color: var(--text-secondary);
    word-break: break-word;
    white-space: pre-line;
}

.agent-notify-time {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.55rem;
}

.agent-notify-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 4rem 1rem;
}

.agent-notify-empty i {
    display: block;
    font-size: 2rem;
    color: var(--primary);
    opacity: 0.65;
    margin-bottom: 0.75rem;
}

.agent-notify-empty strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.agent-notify-delete {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

@media (max-width: 640px) {
    .agent-notify-modal-content {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .agent-notify-header,
    .agent-notify-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .agent-notify-heading p {
        display: none;
    }

    .agent-notify-item {
        padding-left: 0.75rem;
    }
}

.agent-notify-item:hover .agent-notify-delete,
.agent-notify-item:focus-within .agent-notify-delete {
    opacity: 1;
}

.agent-notify-delete:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.agent-notify-delete i {
    margin: 0;
    color: inherit;
}

.agent-notify-item.deleting {
    opacity: 0.55;
    pointer-events: none;
}

@media (hover: none) {
    .agent-notify-delete {
        opacity: 0.75;
    }
}

/* ===== Agent task-proposal card (создание задач из документа) ===== */
.agent-task-proposal-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.agent-task-proposal-scroll {
    overflow-x: auto;
    margin: 0.25rem 0 0.6rem 0;
}

.agent-task-proposal-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85rem;
}

.agent-task-proposal-table th,
.agent-task-proposal-table td {
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.35rem 0.55rem;
    text-align: left;
    vertical-align: top;
}

.agent-task-proposal-description {
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.35;
    max-width: 32rem;
    white-space: normal;
}

body.light-mode .agent-task-proposal-table th,
body.light-mode .agent-task-proposal-table td {
    border-color: rgba(0, 0, 0, 0.15);
}

.agent-task-proposal-skip {
    opacity: 0.6;
}

.agent-task-proposal-create {
    margin-top: 0.25rem;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

/* Confirm+cancel row on proposal cards; ends as a one-line terminal status */
.agent-task-proposal-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.agent-task-proposal-actions .agent-task-proposal-create {
    margin-top: 0;
}

.agent-task-proposal-cancel {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.agent-task-proposal-cancel:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.agent-task-proposal-status {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.agent-task-proposal-status-done {
    color: var(--success);
}

.agent-task-proposal-status-cancelled {
    font-weight: 500;
}

/* Whole card dims once the user cancelled it — the proposal is dead */
.agent-task-proposal-cancelled {
    opacity: 0.55;
}

/* Non-terminal failure (server 4xx/5xx, network): shown inline under the
   still-live buttons so it can't scroll past unseen */
.agent-task-proposal-error {
    flex-basis: 100%;
    font-size: 0.8rem;
    color: var(--danger);
}

.agent-task-proposal-delete {
    background: var(--danger);
    border-color: var(--danger);
}

.agent-task-proposal-delete:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
}

.agent-task-proposal-note {
    font-size: 0.8rem;
    opacity: 0.65;
    margin-top: 0.35rem;
}

.agent-delete-proposal-warning {
    color: var(--danger);
    opacity: 1;
}

/* ===== Project view switcher (sidebar, under active project) ===== */
.project-view-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-left: 1.5rem;
    padding-right: 0.5rem;
    min-width: 0;
    animation: viewSwitchIn 0.18s ease;
}

/* Три кнопки в ширину сайдбара не помещаются: «Календарь» уходит на свою
   строку во всю ширину, «Канбан» и «Гант» делят первую. */
.view-switch-btn[data-pview="calendar"] {
    flex: 1 1 100%;
}

@keyframes viewSwitchIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.view-switch-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.view-switch-btn:hover {
    color: var(--text-primary);
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.08);
}

.view-switch-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.45);
    color: var(--primary);
}

/* ===== Gantt view ===== */
.gantt-container {
    --gantt-surface: #1e293b;
    /* Opaque bg for sticky header/label cells (bars scroll underneath) */
    --gantt-label-w: 220px;
    /* Width of the sticky task-name column; JS positions month/today lines
       with calc() against this var, so keep overrides here, not in JS */
    flex: 1;
    padding: 0 2.5rem 2rem;
    display: none;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

body.light-mode .gantt-container {
    --gantt-surface: #ffffff;
}

.gantt-container.active {
    display: flex;
}

.gantt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.4rem 0.6rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--sidebar-bg);
    backdrop-filter: blur(8px);
}

.gantt-toolbar-controls,
.gantt-period-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.gantt-toolbar-controls {
    gap: 0.65rem;
}

.gantt-period-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.gantt-period-btn:hover {
    border-color: rgba(148, 163, 184, 0.35);
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.08);
}

.gantt-period-select {
    min-width: 118px;
    padding: 0.45rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--gantt-surface);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
}

.gantt-period-select.month-mode {
    min-width: 142px;
}

.gantt-scale-switch {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--gantt-surface);
}

.gantt-scale-btn {
    min-width: 76px;
    height: 28px;
    padding: 0 0.75rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.gantt-scale-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.08);
}

.gantt-scale-btn.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.18);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.35);
}

.gantt-period-btn:focus-visible,
.gantt-period-select:focus-visible,
.gantt-scale-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.gantt-legend {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    padding-right: 0.5rem;
}

.gantt-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.gantt-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.gantt-legend-dot.early {
    background: #22c55e;
}

.gantt-legend-dot.middle {
    background: #eab308;
}

.gantt-legend-dot.late {
    background: #f97316;
}

.gantt-legend-dot.overdue {
    background: #ef4444;
}

.gantt-legend-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.gantt-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-color);
    position: relative;
}

.gantt-table {
    position: relative;
    min-width: 100%;
    width: max-content;
}

/* Year <-> month drill-down zoom. "leave" classes transition the outgoing
   table (origin = clicked month, set inline by JS); "enter" classes animate
   the freshly rendered view from the opposite scale. */
.gantt-table.gantt-leave-in,
.gantt-table.gantt-leave-out {
    transition: transform 0.17s ease, opacity 0.17s ease;
    opacity: 0;
    pointer-events: none;
}

.gantt-table.gantt-leave-in {
    transform: scale(1.12);
}

.gantt-table.gantt-leave-out {
    transform: scale(0.92);
}

.gantt-table.gantt-enter-in {
    animation: ganttEnterIn 0.22s ease;
}

.gantt-table.gantt-enter-out {
    animation: ganttEnterOut 0.22s ease;
}

@keyframes ganttEnterIn {
    from {
        transform: scale(0.92);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

@keyframes ganttEnterOut {
    from {
        transform: scale(1.1);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

/* Header: sticky on top while scrolling vertically; its left cell is also
   sticky horizontally. z-index order: corner (7) > header (6) > row labels (5)
   > today line (3) > bars (2) > month lines (1). */
.gantt-head {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    background: var(--gantt-surface);
}

.gantt-head-left {
    position: sticky;
    left: 0;
    z-index: 7;
    width: var(--gantt-label-w);
    flex: 0 0 var(--gantt-label-w);
    display: flex;
    align-items: flex-end;
    padding: 0.5rem 0.9rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--gantt-surface);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.gantt-head-right {
    border-bottom: 1px solid var(--border);
}

.gantt-months-row,
.gantt-days-row {
    display: flex;
}

.gantt-month {
    flex: 0 0 auto;
    border-left: 1px solid var(--border);
    padding: 0.45rem 0.2rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-month.today {
    color: var(--primary);
}

.gantt-month:first-child {
    border-left: none;
}

.gantt-day {
    flex: 0 0 auto;
    text-align: center;
    font-size: 0.62rem;
    color: var(--text-secondary);
    padding: 8px 0;
}

.gantt-day.weekend {
    opacity: 0.45;
}

.gantt-day.today {
    color: var(--primary);
    font-weight: 700;
    opacity: 1;
}

.gantt-body {
    position: relative;
}

.gantt-row {
    display: flex;
}

.gantt-row-label {
    position: sticky;
    left: 0;
    z-index: 5;
    width: var(--gantt-label-w);
    flex: 0 0 var(--gantt-label-w);
    padding: 0.45rem 0.9rem;
    background: var(--gantt-surface);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease;
}

.gantt-row:hover .gantt-row-label {
    background: var(--card-hover);
}

.gantt-row-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-row-meta {
    font-size: 0.68rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Day grid + weekend shading, both driven by --gantt-day (px per day) set
   inline by renderGantt(). Weekend band phase is aligned via
   --gantt-weekend-offset (depends on the weekday of Jan 1). */
.gantt-row-track {
    position: relative;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border);
    background-image:
        repeating-linear-gradient(90deg,
            rgba(148, 163, 184, 0.08) 0,
            rgba(148, 163, 184, 0.08) calc(var(--gantt-day) * 2),
            transparent calc(var(--gantt-day) * 2),
            transparent calc(var(--gantt-day) * 7)),
        repeating-linear-gradient(90deg,
            var(--border) 0,
            var(--border) 1px,
            transparent 1px,
            transparent var(--gantt-day));
    background-position: var(--gantt-weekend-offset, 0) 0, 0 0;
}

/* Year mode: month columns — grid lines only, no weekend band */
.gantt-table.year-mode .gantt-row-track {
    background-image:
        repeating-linear-gradient(90deg,
            var(--border) 0,
            var(--border) 1px,
            transparent 1px,
            transparent var(--gantt-day));
    background-position: 0 0;
}

/* Filler rows: pad the grid to the bottom of the canvas, a dash per row */
.gantt-row-filler .gantt-row-label {
    cursor: default;
    color: var(--text-secondary);
    opacity: 0.45;
    display: flex;
    align-items: center;
}

.gantt-row-filler:hover .gantt-row-label {
    background: var(--gantt-surface);
}

.gantt-row-label.gantt-row-note {
    opacity: 0.8;
    font-size: 0.78rem;
    white-space: normal;
}

.gantt-bar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    height: 18px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0 8px;
    overflow: hidden;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: filter 0.15s ease, height 0.15s ease;
}

.gantt-bar:hover {
    filter: brightness(1.15);
    height: 22px;
}

.gantt-bar.deadline-early {
    background: #22c55e;
}

.gantt-bar.deadline-middle {
    background: #eab308;
    color: #1e293b;
}

.gantt-bar.deadline-late {
    background: #f97316;
    color: #1e293b;
}

.gantt-bar.deadline-overdue {
    background: #ef4444;
    box-shadow: 0 0 0 2px var(--danger), 0 2px 8px rgba(239, 68, 68, 0.35);
}

/* Bar continues beyond the visible year: square off the clipped edge */
.gantt-bar.clip-left {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.gantt-bar.clip-right {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.gantt-month-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(148, 163, 184, 0.22);
    pointer-events: none;
    z-index: 1;
}

.gantt-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.8);
    pointer-events: none;
    z-index: 3;
}

@media (max-width: 768px) {
    .gantt-container {
        --gantt-label-w: 120px;
        width: 100%;
        min-width: 0;
        padding: 0 0.75rem 0.9rem;
        gap: 0.6rem;
        flex: 1 1 auto;
        min-height: 0;
    }

    .gantt-toolbar {
        width: 100%;
        min-width: 0;
        padding: 0.45rem 0.5rem;
        gap: 0.5rem;
    }

    .gantt-toolbar-controls {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .gantt-period-nav,
    .gantt-scale-switch {
        width: 100%;
        min-width: 0;
    }

    .gantt-period-select,
    .gantt-scale-btn {
        flex: 1;
    }

    .gantt-period-btn {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        font-size: 0.8rem;
    }

    .gantt-period-select {
        width: 0;
        min-width: 0;
        padding: 0.35rem 0.55rem;
        font-size: 0.85rem;
        border-radius: 8px;
        max-width: none;
    }

    .gantt-scale-btn {
        min-width: 66px;
        height: 26px;
        padding: 0 0.55rem;
        font-size: 0.76rem;
    }

    .gantt-legend {
        gap: 0.5rem 0.7rem;
    }

    .gantt-legend-item {
        font-size: 0.72rem;
    }

    .gantt-legend-note {
        font-size: 0.68rem;
        width: 100%;
    }

    .gantt-head-left,
    .gantt-row-label {
        padding: 0.4rem 0.6rem;
    }

    .gantt-row-title {
        font-size: 0.76rem;
    }

    .gantt-row-meta {
        font-size: 0.62rem;
    }

    .gantt-month {
        font-size: 0.7rem;
    }

    .gantt-bar {
        font-size: 0.6rem;
        padding: 0 5px;
    }

    /* Sidebar Канбан/Гант switcher: comfortable touch targets */
    .view-switch-btn {
        padding: 0.55rem 0.6rem;
        font-size: 0.8rem;
    }
}
