/* Светлая минималистичная тема */
:root { 
    --bg: #ffffff; 
    --fg: #1e2330; 
    --muted: #616b7a; 
    --accent: #2f6df6; 
    --border: #e8ecf3; 
    --tab: #f6f8fc; 
    --tab-active: #eef2fb; 
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { 
    background: var(--bg); 
    color: var(--fg); 
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif; 
}
.app { display: flex; flex-direction: column; height: 100vh; }

/* Вкладки */
.tabs { 
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.tabs-title { 
    font-size: 30px;
    font-weight: 700;
    color: var(--fg);
    white-space: nowrap;
    flex-shrink: 0;
}
.tabs-title img,
img.tabs-title {
    height: 30px;
    width: auto;
    display: block;
    margin-right: 4px;
}

.tab { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    background: var(--tab); 
    color: var(--muted); 
    border: 1px solid var(--border); 
    border-radius: 12px; 
    padding: 10px; 
    white-space: nowrap; 
    cursor: pointer; 
    user-select: none; 
    transition: background .15s, color .15s, border-color .15s, transform .06s, box-shadow .15s; 
    height: 40px; 
    position: relative; 
    text-decoration: none;
}
.tab.active { background: var(--tab-active); color: var(--fg); border-color: #d8def0; }
.tab:hover { border-color: #d0d8eb; color: var(--fg); }
.tab:active { transform: translateY(1px); }
.tab .title { font-weight: 500; letter-spacing: 0.2px; font-size: 16px; padding: 0 10px; }

.content { flex: 1; overflow: hidden; }
.dashboard { height: 100%; display: none; }
.dashboard[aria-hidden="false"] { display: block; }

/* Таск-трекер */
.tasks-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 14px;
    overflow: hidden;
    position: relative;
}

.tasks-header {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    overflow-y: visible;
}

.search-box {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--bg);
    color: var(--fg);
    transition: border-color .15s;
}
.search-box:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-group {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    transition: all .15s;
}
.filter-btn:hover {
    color: var(--fg);
    border-color: #d0d8eb;
    background: var(--tab);
}
.filter-btn.active {
    background: var(--tab-active);
    color: var(--fg);
    border-color: #d8def0;
}

.group-select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--fg);
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    width: 180px;
}

.add-task-btn {
    padding: 10px 20px;
    border: 1px solid var(--accent);
    border-radius: 12px;
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.add-task-btn:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.view-toggle {
    display: flex;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    background: var(--tab);
    flex-shrink: 0;
}

.view-toggle-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.view-toggle-btn:hover {
    background: var(--tab-active);
    color: var(--fg);
}
.view-toggle-btn.active {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
}
.view-toggle-btn svg {
    width: 16px;
    height: 16px;
}

.tasks-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

/* CRM */
.crm-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 14px;
    overflow: hidden;
}

.crm-header {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.crm-board-wrapper {
    flex: 1;
    overflow: auto;
}

.crm-board .crm-column {
    min-width: 280px;
}

.crm-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px 8px 4px;
}

.crm-stage-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--fg);
}

.crm-stage-edit {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}

.crm-stage-edit:hover {
    background: var(--tab);
    color: var(--fg);
}

.crm-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.crm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.crm-card-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--fg);
}

.crm-card-amount {
    font-size: 14px;
    color: #2563eb;
    font-weight: 600;
}

.crm-card-project {
    font-size: 13px;
    color: var(--muted);
}

.crm-card-description {
    font-size: 13px;
    color: var(--muted);
}

.crm-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.crm-card-dates {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.crm-archive {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.crm-archive-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-card-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--fg);
}

.crm-card-row-multiline {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.crm-card-row-tags {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.crm-card-row-tags .crm-card-tags {
    justify-content: flex-start;
}

.crm-card-label {
    color: var(--muted);
}

.crm-result-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.crm-result-badge.result-success {
    background: #dcfce7;
    color: #15803d;
}

.crm-result-badge.result-failed {
    background: #fee2e2;
    color: #b91c1c;
}

.project-deals {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.project-deals-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}

.project-deals-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.project-deal-link {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px;
    background: transparent;
    font-size: 12px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.project-deal-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tasks-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.tasks-table thead {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 1;
}

.tasks-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.tasks-table th:first-child {
    min-width: 300px;
}

.tasks-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

.tasks-table tbody tr {
    cursor: pointer;
    transition: background .15s;
}

.tasks-table tbody tr:hover {
    background: var(--tab);
}

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

.task-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all .15s;
    position: relative;
}
.task-card:hover {
    border-color: #d0d8eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.task-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--fg);
    flex: 1;
}

.task-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.task-table-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
}

.task-table-name:hover {
    text-decoration: underline;
}

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

.task-table-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.task-table-tag {
    padding: 2px 8px;
    background: var(--tab);
    border: 1px dashed var(--border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--muted);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.status-todo { background: #f8f9fa; color: #6c757d; border: 1px solid #dee2e6; }
.status-in-progress { background: #fffbeb; color: #f59e0b; border: 1px solid #fcd34d; }
.status-done { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.status-cancelled { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }

.priority-badge {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}
.priority-low { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.priority-medium { background: #fffbeb; color: #f59e0b; border: 1px solid #fcd34d; }
.priority-high { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }

.task-description {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.task-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag {
    padding: 4px 10px;
    background: var(--tab);
    border: 1px dashed var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--muted);
}

.task-dates {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
}

/* Канбан доска */
.kanban-board {
    display: flex;
    gap: 16px;
    height: 100%;
    overflow-x: auto;
    padding-bottom: 8px;
}

.kanban-column {
    flex: 1;
    min-width: 280px;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    transition: all .15s;
}
.kanban-column.drag-over {
    background: var(--tab-active);
    border-color: var(--accent);
}

.kanban-column-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.kanban-column-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kanban-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all .15s;
}
.kanban-card:hover {
    border-color: #d0d8eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.kanban-card.dragging {
    opacity: 0.5;
}
.kanban-card.overdue {
    border-left: 4px solid #dc2626;
}

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

.kanban-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
    flex: 1;
}

.kanban-card-description {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
    line-height: 1.4;
}

.kanban-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.kanban-card-deadline {
    font-size: 11px;
    color: var(--muted);
}

.group-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--fg);
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.task-group {
    margin-bottom: 24px;
}

/* Просмотр задачи */
.task-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.task-view-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-view-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task-view-value {
    font-size: 14px;
    color: var(--fg);
    line-height: 1.5;
}

.task-comments-list {
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.task-comments-empty {
    color: var(--muted);
    font-size: 14px;
    font-style: italic;
    padding: 12px;
    text-align: center;
}

.task-comment {
    background: var(--tab);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}

.task-comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.task-comment-date {
    font-size: 12px;
    color: var(--muted);
}

.task-comment-delete {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all .15s;
}

.task-comment-delete:hover {
    background: var(--border);
    color: var(--fg);
}

.task-comment-text {
    font-size: 14px;
    color: var(--fg);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.task-comment-form {
    margin-top: 16px;
}

.task-comment-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
    resize: vertical;
    min-height: 60px;
    box-sizing: border-box;
}

.task-comment-input:focus {
    outline: none;
    border-color: var(--accent);
}


/* Mind Map */
.mindmap-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--bg);
    overflow: hidden;
    cursor: grab;
    display: flex;
    flex-direction: column;
}
.mindmap-container:active {
    cursor: grabbing;
}

.mindmap-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: transparent;
    z-index: 1000;
    flex-shrink: 0;
}

.mindmap-header-left {
    flex: 1;
}

.mindmap-project-name {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--fg);
}

.mindmap-header-right {
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 1001;
    position: relative;
}

.mindmap-canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 20000px;
    height: 20000px;
    transform-origin: 0 0;
    pointer-events: none;
    overflow: visible;
}

.mindmap-canvas > * {
    pointer-events: auto;
}

.mindmap-node {
    position: absolute;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 150px;
    max-width: 400px;
    cursor: move;
    transition: box-shadow .15s;
    z-index: 10;
    box-sizing: border-box;
    display: block;
    visibility: visible;
    opacity: 1;
    width: fit-content;
    height: fit-content;
}
.mindmap-node:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 20;
}
.mindmap-node.dragging {
    opacity: 0.8;
    z-index: 1000;
}

.mindmap-node-selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.mindmap-node-header {
    font-weight: 600;
    font-size: 14px;
    color: var(--fg);
    margin-bottom: 8px;
}

.mindmap-node-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.mindmap-node-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.mindmap-node-dates {
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.4;
}

.mindmap-node-description {
    font-size: 12px;
    color: var(--muted);
    margin-top: 8px;
    line-height: 1.4;
}

.connection-point {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #cbd5e1;
    border: 2px solid white;
    cursor: pointer;
    z-index: 1000;
    transform: translate(-50%, -50%) scale(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    opacity: 0;
    transition: transform 0.15s ease-out, opacity 0.15s ease-out, background 0.15s;
    pointer-events: none;
    left: 0;
    top: 0;
}

.connection-point-visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: all;
}

.connection-point:hover {
    transform: translate(-50%, -50%) scale(1.3);
    background: #94a3b8;
}

.mindmap-node-tag {
    font-size: 11px;
    padding: 2px 6px;
    background: var(--tab);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
}

.mindmap-connection {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.mindmap-toolbar {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 8px;
    z-index: 100;
    background: var(--bg);
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.mindmap-container > .mindmap-container {
    flex: 1;
    overflow: hidden;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.toolbar-btn:hover {
    color: var(--fg);
    border-color: #d0d8eb;
    background: var(--tab);
}
.toolbar-btn svg {
    width: 16px;
    height: 16px;
}

/* Модальные окна */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: stretch;
    justify-content: flex-end;
}
.modal[aria-hidden="false"] {
    display: flex;
}
.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 35, 48, 0.4);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: var(--bg);
    border-left: 1px solid var(--border);
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
    width: 66.666%;
    max-width: 90vw;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
}
.modal[aria-hidden="false"] .modal-content {
    transform: translateX(0);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
}
.modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
}
.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px dashed var(--border);
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.modal-close:hover {
    color: #dc2626;
    border-color: #fca5a5;
    background: #fef2f2;
}
.modal-close svg {
    width: 14px;
    height: 14px;
}
.modal-body {
    padding: 0px 24px 24px 24px;
    overflow-y: auto;
    overflow-x: visible;
    flex: 1;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
    position: relative;
    contain: layout;
    /* Компенсируем ширину скроллбара, чтобы контент не смещался */
    scrollbar-gutter: stable;
}

/* Формы */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--fg);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--bg);
    color: var(--fg);
    transition: border-color .15s;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}
.form-group textarea {
    resize: vertical;
    min-height: 100px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row .form-group {
    min-width: 0;
}

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

.btn-primary {
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}
.btn-secondary {
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.btn-secondary:hover {
    color: var(--fg);
    border-color: #d0d8eb;
    background: var(--tab);
}
.btn-danger {
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px dashed var(--border);
    background: transparent;
    color: #dc2626;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.btn-danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

/* Проекты */
.projects-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 14px;
    overflow: hidden;
}

.projects-header {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.projects-grid {
    display: flex;
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    padding-right: 8px;
    padding-bottom: 8px;
}

.project-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all .15s;
    min-width: 280px;
    max-width: 320px;
    height: fit-content;
    flex-shrink: 0;
}
.project-card:hover {
    border-color: #d0d8eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.project-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 8px;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.project-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--fg);
    flex: 1;
}

.project-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.project-description {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.project-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.project-dates {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
}

.project-card.overdue {
    border-left: 4px solid #dc2626;
}

/* Пустое состояние */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted);
    text-align: center;
    padding: 24px;
}
.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--fg);
}
.empty-state p {
    font-size: 14px;
}

/* Скроллбар */
.tasks-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.projects-grid::-webkit-scrollbar {
    width: 6px;
}
.tasks-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.projects-grid::-webkit-scrollbar-track {
    background: transparent;
}
.tasks-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.projects-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.tasks-content::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.projects-grid::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* Кастомные селекты */
.custom-select {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    z-index: 1;
    display: block;
    visibility: visible;
    opacity: 1;
}

.custom-select.open {
    z-index: 100002;
}

.custom-select-button {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    transition: border-color .15s;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.custom-select-button::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--muted);
    transition: transform .15s;
}

.custom-select.open .custom-select-button::after {
    transform: rotate(180deg);
}

.custom-select-button:hover,
.custom-select.open .custom-select-button {
    border-color: var(--accent);
}

.custom-select-dropdown {
    position: absolute;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100001;
    max-height: 176px; /* 4 пункта по 44px каждый */
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    box-sizing: border-box;
    opacity: 1;
    visibility: visible;
    margin: 0;
    padding: 0;
    transform: none;
    top: calc(100% + 4px);
    left: 0;
    right: auto;
}

.custom-select-option {
    padding: 10px 14px;
    cursor: pointer;
    transition: background .15s;
    font-size: 14px;
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
    box-sizing: border-box;
    min-height: 44px; /* Фиксированная высота для каждого пункта */
    display: flex;
    align-items: center;
}

.custom-select-option:hover {
    background: var(--tab);
}

.custom-select-option.selected {
    background: var(--tab-active);
    color: var(--accent);
    font-weight: 500;
}

/* Кастомный календарь */
.custom-datepicker {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    z-index: 1;
}

.custom-datepicker.open {
    z-index: 100004; /* Выше чем custom-select.open (100002) */
}


.custom-datepicker-button {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    transition: border-color .15s;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    flex-shrink: 0;
    /* Фиксируем размеры, чтобы border не влиял на ширину */
    border-width: 1px;
    /* Предотвращаем изменение размеров при пересчете layout */
    will-change: border-color;
}

.custom-datepicker-button.placeholder {
    color: var(--muted);
}

.custom-datepicker-button::after {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%23616b7a' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.6;
}

.custom-datepicker-button:hover,
.custom-datepicker.open .custom-datepicker-button {
    border-color: var(--accent);
    border-width: 1px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 10px 14px !important;
}

.custom-datepicker-calendar {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 999999; /* Очень высокий z-index, чтобы быть выше всех элементов */
    padding: 12px;
    width: 280px;
    box-sizing: border-box;
    display: none;
    margin: 0;
    /* Календарь не должен влиять на размеры родительского контейнера */
    contain: layout style paint;
}

.datepicker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.datepicker-nav {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--tab);
    color: var(--fg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}

.datepicker-nav:hover {
    background: var(--tab-active);
    border-color: var(--accent);
}

.datepicker-nav svg {
    width: 14px;
    height: 14px;
}

.datepicker-month-year {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
}

.datepicker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 6px;
}

.datepicker-weekday {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    padding: 4px 0;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
}

.datepicker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 8px;
}

.datepicker-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--fg);
    transition: all .15s;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
    min-height: 28px;
}

.datepicker-day.empty {
    cursor: default;
}

.datepicker-day:hover:not(.empty) {
    background: var(--tab);
}

.datepicker-day.today {
    border: 1px solid var(--accent);
    font-weight: 600;
}

.datepicker-day.selected {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.datepicker-clear {
    width: 100%;
    padding: 6px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    transition: all .15s;
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Inter, Arial, sans-serif;
}

.datepicker-clear:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--tab);
}

