/* AxesPipeline — общие стили (axes-theme inspired) */
:root {
    --bg: #EDEAE2;
    --surface: #FFFFFF;
    --surface-2: #F6F3EB;
    --border: #E2DFD6;
    --border-focus: #C8271A;
    --text: #1A1816;
    --text-secondary: #5C5850;
    --text-muted: #9C9890;
    --accent: #C8271A;
    --accent-dark: #9E1F14;
    --success: #10B981;
    --warning: #F59E0B;
    --info: #6366F1;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 12px rgba(0,0,0,0.06);
    /* Цвета командного Gantt по ответственному */
    --c-axes: #C8271A;
    --c-joint: #6366F1;
    --c-client: #6B7280;
    --c-done: #10B981;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
}

/* ── Header ─────────────────────── */
header.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand {
    font-weight: 700;
    font-size: 17px;
    padding: 14px 0;
    margin-right: 24px;
}
.brand .accent { color: var(--accent); }
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 14px 0;
}

/* Tabs */
.tabs {
    display: flex;
    flex: 1;
    gap: 4px;
    height: 100%;
    align-items: stretch;
}
.tab {
    padding: 18px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab .badge {
    background: var(--surface-2);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
}
.tab.active .badge {
    background: var(--accent);
    color: white;
}

/* List view (для terminal stages) */
.list-view {
    padding: 20px 28px;
}
.list-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.list-view-header h2 {
    font-size: 18px;
    font-weight: 600;
}
.list-view-extra { margin-left: auto; }
.lead-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    width: 100%;
    border-collapse: collapse;
}
.lead-table th {
    background: var(--surface-2);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.lead-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.lead-table tr { cursor: pointer; transition: background 0.1s; }
.lead-table tr:hover { background: var(--surface-2); }
.lead-table tr:last-child td { border-bottom: none; }

/* Аккаунты модалка */
.accounts-list {
    margin-bottom: 16px;
}
.account-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.account-row:last-child { border-bottom: none; }
.account-row .color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}
.account-row .name { font-weight: 500; }
.account-row .email { color: var(--text-muted); font-size: 12px; }
.account-row .info { flex: 1; min-width: 0; }
.account-row .actions { display: flex; gap: 4px; }
.add-account-form {
    background: var(--surface-2);
    padding: 14px;
    border-radius: 8px;
    margin-top: 10px;
}

/* ── Buttons ────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: white; }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Kanban ─────────────────────── */
.kanban {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    padding: 20px;
    height: calc(100vh - 60px);
    overflow-x: auto;
    min-width: 0;
}
.kanban-column {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    min-width: 220px;
    overflow: hidden;
}
.kanban-column-header {
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.kanban-column-header .count {
    background: var(--border);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.kanban-column-body {
    padding: 10px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Lead Card (на канбане) ─────── */
.lead-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}
.lead-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.lead-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}
.kanban-column-body.drag-over {
    background: rgba(200, 39, 26, 0.05);
    box-shadow: inset 0 0 0 2px var(--accent);
    border-radius: 8px;
}
.lead-card .name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}
.lead-card .company {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 8px;
}
.lead-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.lead-card .pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.lead-card .pill.value { color: var(--text); font-weight: 600; }
.lead-card .footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
}
.lead-card .account-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.lead-card .account-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}
.lead-card .timer {
    font-weight: 500;
}
.lead-card .timer.warning { color: var(--warning); }
.lead-card .timer.danger { color: var(--accent); }

/* ── Modal ──────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    width: 540px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h2 {
    font-size: 18px;
    margin-bottom: 16px;
}
.modal .form-row { margin-bottom: 14px; }
.modal label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}
.modal input, .modal select, .modal textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.modal input:focus, .modal select:focus, .modal textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.modal textarea { min-height: 80px; resize: vertical; }
.modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}
.modal .form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ── Lead Detail Page ───────────── */
.detail-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}
.detail-container.client-mode {
    max-width: 1400px;  /* шире для клиентского кабинета */
}
/* Секция, которая «вырывается» из контейнера на всю ширину viewport'а
   (использовать для большого Gantt'а) */
.detail-container.client-mode .section-fullwidth {
    margin-left: calc(50% - 50vw + 16px);
    margin-right: calc(50% - 50vw + 16px);
}
.detail-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
}
.detail-back:hover { color: var(--accent); }

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
}
.detail-header h1 { font-size: 24px; margin-bottom: 4px; }
.detail-header .subtitle { color: var(--text-secondary); font-size: 14px; }

.stage-badge {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.stage-badge.new          { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.stage-badge.preparing    { background: #E0E7FF; color: #4338CA; border-color: #C7D2FE; }
.stage-badge.in_contact   { background: #DDD6FE; color: #5B21B6; border-color: #C4B5FD; }
.stage-badge.kp_preparing { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.stage-badge.kp_sent      { background: #FED7AA; color: #9A3412; border-color: #FDBA74; }
.stage-badge.client       { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; }
.stage-badge.deferred     { background: #FEF9C3; color: #854D0E; border-color: #FDE047; }
.stage-badge.planned      { background: #DBEAFE; color: #1E40AF; border-color: #93C5FD; }
.stage-badge.refused      { background: #FEE2E2; color: #991B1B; border-color: #FECACA; }
.stage-badge.archived     { background: var(--border); color: var(--text-muted); }

/* Бейдж "из архива #N" — для лидов, созданных как новый цикл */
.parent-cycle-badge {
    display: inline-flex; align-items: center; gap: 4px;
    margin-left: 10px;
    padding: 2px 9px; border-radius: 100px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
    background: rgba(99,102,241,0.12);
    color: #4338CA;
    border: 1px solid rgba(99,102,241,0.35);
    text-decoration: none;
    vertical-align: middle;
    transition: background 0.12s;
}
.parent-cycle-badge:hover {
    background: rgba(99,102,241,0.22);
    text-decoration: none;
}

/* ── Голосовой ввод (Web Speech API) ─────────────────── */
.voice-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: all 0.15s;
    z-index: 5;
    padding: 0;
    user-select: none;
}
.voice-btn:hover {
    border-color: var(--accent);
    background: var(--surface-2);
    transform: translateY(-1px);
}
.voice-btn.recording {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    animation: voice-pulse 1.2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(200,39,26,0.45); }
    50%      { box-shadow: 0 0 0 10px rgba(200,39,26,0); }
}
/* Чтобы кнопка не залезала на текст — небольшой right-padding на textarea */
textarea[data-voice="1"] {
    padding-right: 44px !important;
}

/* ═══════════════════════════════════════════════════
   Hub-режим (?hub=1) — встраивание в AXES HUB iframe.
   Pipeline становится прозрачным «слоем» поверх фона хаба.
   ═══════════════════════════════════════════════════ */
/* Перебиваем CSS-переменную фона — теперь body не подкрашивается */
.hub-mode { --bg: transparent !important; }
html.hub-mode,
body.hub-mode,
.hub-mode body,
.hub-mode html {
    background: transparent !important;
}
/* Скрываем собственный брендинг — у хаба свой toolbar с именем модуля */
.hub-mode .brand,
html.hub-mode .brand,
body.hub-mode .brand {
    display: none !important;
}
/* Прозрачная шапка — табы становятся «парящими» поверх фона хаба */
.hub-mode .app-header,
html.hub-mode .app-header,
body.hub-mode .app-header {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom-color: rgba(0,0,0,0.07) !important;
}
/* Лента-список (Архив/Клиенты/Отказы/Архив) — тоже без подложки */
.hub-mode .detail-container,
.hub-mode .list-view,
.hub-mode .kanban {
    background: transparent !important;
}

/* Тёмная тема хаба */
html.hub-mode.dark-theme {
    color: #E2E8F0;
}
html.hub-mode.dark-theme .tab,
html.hub-mode.dark-theme .breadcrumb {
    color: #94A3B8;
}
html.hub-mode.dark-theme .tab.active { color: var(--accent); }
html.hub-mode.dark-theme .app-header {
    border-bottom-color: rgba(255,255,255,0.08) !important;
}
/* В тёмной теме хаба белые карточки слегка приглушаем */
html.hub-mode.dark-theme .section,
html.hub-mode.dark-theme .lead-card,
html.hub-mode.dark-theme .kanban-column {
    background: rgba(30,30,35,0.55);
    color: #E2E8F0;
}
.stage-badge.not_lead     { background: var(--border); color: var(--text-muted); }

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 14px;
}
.section h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.section .row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}
.section .row .label { color: var(--text-muted); }
.section .row .value { font-weight: 500; }

/* Сворачиваемая секция */
.section.collapsible h3 {
    cursor: pointer;
    user-select: none;
}
.section.collapsible h3::after {
    content: '▾';
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.15s;
}
.section.collapsible.collapsed h3::after { transform: rotate(-90deg); }
.section.collapsible.collapsed > *:not(h3) { display: none; }
.section.collapsible.collapsed h3 { margin-bottom: 0; }

/* Сводка inline (для шапки клиентского кабинета) */
.summary-inline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 14px;
}
.summary-inline .item .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.summary-inline .item .value {
    font-size: 14px;
    font-weight: 500;
}

/* ── Activity Timeline ─────────── */
.activity-list {
    list-style: none;
    margin-top: 8px;
}
.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin: 0 -12px;
    border-radius: 8px;
    border-bottom: 1px solid var(--border);
    position: relative;
    transition: background 0.15s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item.important {
    background: linear-gradient(90deg, #FEF3C7 0%, #FEF9C3 100%);
    border-bottom-color: #FDE68A;
}
.activity-item.important .activity-icon { background: #FDE68A; }
.activity-item:hover { background: rgba(0,0,0,0.02); }
.activity-item.important:hover { background: linear-gradient(90deg, #FDE68A 0%, #FEF3C7 100%); }
.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.activity-content { flex: 1; min-width: 0; }
.activity-content .type {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}
.activity-content .time { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.activity-content .time .edited-mark { color: var(--text-muted); font-style: italic; margin-left: 6px; }
.activity-content .note { color: var(--text-secondary); font-size: 13px; white-space: pre-wrap; }
.activity-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.activity-item:hover .activity-actions,
.activity-item.important .activity-actions { opacity: 1; }
.activity-action-btn {
    width: 28px; height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.15s;
}
.activity-action-btn:hover { background: var(--surface-2); color: var(--text); }
.activity-action-btn.star.active { color: #F59E0B; }

/* ── Inline editable fields ─────── */
.editable-value {
    cursor: pointer;
    padding: 2px 6px;
    margin: -2px -6px;
    border-radius: 4px;
    transition: background 0.1s;
    border: 1px solid transparent;
}
.editable-value:hover {
    background: var(--surface-2);
    border-color: var(--border);
}
.editable-value.empty { color: var(--text-muted); font-style: italic; }
.editable-input,
.editable-select,
textarea.editable-input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: white;
    box-sizing: border-box;
}
textarea.editable-input { min-height: 80px; }
/* H1 inline-edit — крупный шрифт чтоб не прыгал */
h1 .editable-value {
    font-size: inherit;
    font-weight: inherit;
}
h1 .editable-input {
    font-size: 24px;
    font-weight: 700;
    padding: 4px 8px;
}
.section .row.editing .value { width: 60%; }

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 24px 0;
    font-size: 13px;
}

/* ── Checklist ──────────────────── */
.checklist-stage {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.checklist-stage-header {
    background: var(--surface-2);
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 13px;
    user-select: none;
}
.checklist-stage-header:hover { background: #EDE9DD; }
.checklist-stage-header .progress {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}
.checklist-stage-header .progress.complete { color: var(--success); }
.checklist-stage-header .chevron { transition: transform 0.15s; }
.checklist-stage.open .chevron { transform: rotate(90deg); }
.checklist-items { display: none; padding: 0; }
.checklist-stage.open .checklist-items { display: block; }

.checklist-item {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: start;
}
.checklist-item.done { background: #F0FDF4; }
.checklist-item.in_progress { background: #FFFBEB; }
.checklist-item.skipped {
    background: #F3F4F6;
    opacity: 0.6;
    padding-top: 6px;
    padding-bottom: 6px;
}
.checklist-item.skipped .item-title {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: line-through;
}
.checklist-item.skipped .desc-toggle,
.checklist-item.skipped .desc,
.checklist-item.skipped .item-note { display: none; }
.checklist-item .status-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    background: white;
    cursor: pointer;
    min-width: 110px;
}
.checklist-item .body {
    min-width: 0;
}
.checklist-item .item-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}
.checklist-item.done .item-title { text-decoration: line-through; color: var(--text-muted); }
.checklist-item .item-id {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    margin-right: 6px;
}
.checklist-item .desc-toggle {
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    margin-left: 6px;
}
.checklist-item .desc-toggle:hover { color: var(--accent); }
.checklist-item .desc {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--surface-2);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: none;
}
.checklist-item.expanded .desc { display: block; }
.checklist-item .item-note {
    margin-top: 6px;
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    min-height: 32px;
    background: white;
}
.checklist-item .item-note:focus { outline: none; border-color: var(--accent); }

.service-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.service-tab {
    padding: 6px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.service-tab:hover { border-color: var(--accent); color: var(--accent); }
.service-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.service-tab.no-template { opacity: 0.6; cursor: not-allowed; }
.service-tab.no-template:hover { border-color: var(--border); color: var(--text-muted); }

/* ── iOS-style switch ─────────────── */
.ios-switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
}
.ios-switch input { opacity: 0; width: 0; height: 0; }
.ios-switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #d1d5db;
    border-radius: 999px;
    transition: 0.18s;
}
.ios-switch-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: 0.18s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.ios-switch input:checked + .ios-switch-slider { background: var(--success); }
.ios-switch input:checked + .ios-switch-slider::before { transform: translateX(14px); }
.ios-switch.consultant input:checked + .ios-switch-slider { background: #6366F1; }  /* индиго */
.ios-switch.client input:checked + .ios-switch-slider { background: var(--accent); }   /* axes-red */
.ios-switch.client-side input:checked + .ios-switch-slider { background: #F59E0B; }  /* янтарный — "ждём клиента" */

/* ── Ключевые даты проекта (milestones) ──────────────── */
.milestones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 4px;
}
.milestone {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--ms-color, var(--accent));
    border-radius: 10px;
    padding: 12px 14px;
}
.milestone .ms-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}
.milestone .ms-dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ms-color, var(--accent));
}
.milestone input[type="date"] {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid transparent; border-radius: 8px;
    background: var(--surface-2); font-family: inherit; font-size: 14px;
    color: var(--text); font-variant-numeric: tabular-nums;
    box-sizing: border-box;
    transition: all 0.12s;
}
.milestone input[type="date"]:hover { background: #ECE8DD; }
.milestone input[type="date"]:focus {
    outline: none; background: var(--surface);
    border-color: var(--ms-color, var(--accent));
    box-shadow: 0 0 0 3px rgba(200,39,26,0.08);
}

/* Бейдж "👤 у клиента" — в заголовке пункта чек-листа и в строке cg-таблицы */
.cs-badge {
    display: inline-flex; align-items: center; gap: 4px;
    margin-left: 8px;
    padding: 2px 9px; border-radius: 100px;
    font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(245,158,11,0.15);
    color: #B45309;
    border: 1px solid rgba(245,158,11,0.35);
    vertical-align: middle;
    white-space: nowrap;
}
.cs-badge-row {
    padding: 0 12px 2px 14px;
    margin-top: -2px;
}
.cs-badge-row .cs-badge { margin-left: 0; }
.checklist-item.on-client {
    background: linear-gradient(90deg, rgba(245,158,11,0.05) 0%, rgba(245,158,11,0) 60%);
}
.tasks-grid .tg-row.cg-on-client {
    background: linear-gradient(90deg, rgba(245,158,11,0.06) 0%, rgba(245,158,11,0) 60%);
}

/* Свитчи в правой колонке checklist-item */
.gantt-switches {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}
.gantt-switches .switch-row {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.gantt-switches .switch-row:hover { color: var(--text); }
.gantt-switches .switch-row.active { color: var(--text); font-weight: 500; }

/* ── Gantt section ─────────────────── */
.gantt-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}
.gantt-tab {
    padding: 8px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    border-bottom: 1px solid var(--border);
}
.gantt-tab:hover { background: #EDE9DD; }
.gantt-tab.active {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}
.gantt-iframe {
    width: 100%;
    height: 700px;
    border: 1px solid var(--border);
    border-radius: 0 8px 8px 8px;
    background: var(--surface);
}
.gantt-empty {
    padding: 40px 20px;
    text-align: center;
    background: var(--surface-2);
    border-radius: 8px;
}
.gantt-empty p { margin-bottom: 14px; color: var(--text-secondary); }

/* ── Toast ──────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: var(--shadow);
    z-index: 200;
    animation: slide-in 0.2s ease;
}
@keyframes slide-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ═══════════════════════════════════════════════════
   Консультантский (нативный) Gantt — таблица задач + диаграмма
   Адаптировано из CompAxes (project.css), без брендинга/share-кнопок.
   ═══════════════════════════════════════════════════ */
.cg-host {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 6px;
}
.cg-action-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.cg-mini-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 100px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}
.cg-empty-row {
    padding: 28px 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}
.cg-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

/* Tasks GRID — Grid-строки */
.tasks-grid {
    font-size: 14.5px;
    min-width: 1100px;
}
.tasks-grid .tg-head,
.tasks-grid .tg-row {
    display: grid;
    grid-template-columns:
        36px            /* drag */
        minmax(320px, 1fr)  /* title */
        152px           /* start date */
        152px           /* end date */
        72px            /* раб */
        72px            /* кален */
        160px           /* ownership */
        70px            /* готово */
        44px;           /* delete */
    align-items: center;
}
.tasks-grid .tg-center { text-align: center; }

.tasks-grid .tg-head {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.tasks-grid .tg-head > div { padding: 12px 12px; }

.tasks-grid .tg-row {
    position: relative;
    border-bottom: 1px solid #F1EEE4;
    transition: background 0.12s;
}
.tasks-grid .tg-row > div { padding: 6px 12px; min-width: 0; }
.tasks-grid .tg-row::before {
    content: ''; position: absolute; left: 0; top: 3px; bottom: 3px;
    width: 16px; border-radius: 0 6px 6px 0;
    background: var(--row-color, transparent);
    transition: width 0.15s;
}
.tasks-grid .tg-row:hover { background: #FBFAF4; }
.tasks-grid .tg-row:hover::before { width: 20px; }
.tasks-grid .tg-row[data-own="axes"] { --row-color: var(--c-axes); }
.tasks-grid .tg-row[data-own="joint"] { --row-color: var(--c-joint); }
.tasks-grid .tg-row[data-own="client"] { --row-color: var(--c-client); }
.tasks-grid .tg-row.is-done { --row-color: var(--c-done); opacity: 0.55; }
.tasks-grid .tg-row.is-done textarea.f-title { text-decoration: line-through; }

.tasks-grid .tg-row.is-active {
    --row-color: #F59E0B;
    background: linear-gradient(90deg, rgba(245,158,11,0.08) 0%, rgba(245,158,11,0) 100%);
}
.tasks-grid .tg-row.is-active::before {
    width: 20px;
    box-shadow: 0 0 0 4px rgba(245,158,11,0.15);
}

/* Title textarea */
.tasks-grid .tg-title { display: flex; flex-direction: column; gap: 2px; }
.tasks-grid textarea.f-title {
    width: 100%; padding: 7px 12px;
    border: 1.5px solid transparent; border-radius: 8px;
    background: transparent; font-family: inherit; font-size: 14.5px;
    color: var(--text); font-weight: 500; line-height: 1.4;
    resize: none; min-height: 36px; max-height: 76px; overflow-y: auto;
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    transition: all 0.12s;
}
.tasks-grid textarea.f-title:hover { background: var(--surface); border-color: #E5E1D5; }
.tasks-grid textarea.f-title:focus {
    outline: none; background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200,39,26,0.08);
}

/* Inline notes */
.tasks-grid .inline-note {
    display: flex; align-items: flex-start; gap: 6px;
    padding: 1px 0 0 12px;
    opacity: 0.6;
    transition: opacity 0.12s;
}
.tasks-grid .inline-note:hover,
.tasks-grid .inline-note:focus-within,
.tasks-grid .inline-note.filled { opacity: 1; }
.tasks-grid .inline-note-icon {
    font-size: 12px; line-height: 1.6;
    color: var(--text-muted); user-select: none;
}
.tasks-grid .inline-note.filled .inline-note-icon { color: var(--accent); }
.tasks-grid textarea.f-notes {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
    resize: none;
    height: 26px;
    min-height: 26px;
    max-height: 140px;
    overflow-y: auto;
    display: block;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
    transition: height 0.12s, background 0.12s, border-color 0.12s;
}
.tasks-grid textarea.f-notes::placeholder {
    color: var(--text-muted); font-style: italic;
}
.tasks-grid textarea.f-notes:hover { background: var(--surface); border-color: #E5E1D5; }
.tasks-grid textarea.f-notes:focus {
    outline: none; background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200,39,26,0.08);
    color: var(--text);
}
.tasks-grid .inline-note.filled textarea.f-notes { color: var(--text); }

/* Dates */
.tasks-grid input[type="date"] {
    width: 100%;
    padding: 7px 8px 7px 10px;
    border: 1.5px solid transparent; border-radius: 8px;
    background: var(--surface-2); font-family: inherit; font-size: 13px;
    color: var(--text); font-variant-numeric: tabular-nums;
    transition: all 0.12s;
    box-sizing: border-box;
}
.tasks-grid input[type="date"]:hover { background: #ECE8DD; }
.tasks-grid input[type="date"]:focus {
    outline: none; background: var(--surface); border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200,39,26,0.08);
}

/* Days numbers */
.tasks-grid .tg-wd, .tasks-grid .tg-cd {
    text-align: center;
    font-variant-numeric: tabular-nums; font-weight: 600;
    color: var(--text-secondary); font-size: 13.5px;
}

/* Drag */
.tasks-grid .tg-drag {
    text-align: center; cursor: grab; user-select: none;
    color: var(--text-muted); font-size: 16px; letter-spacing: -1px;
    transition: color 0.15s;
}
.tasks-grid .tg-row:hover .tg-drag { color: var(--text-secondary); }
.tasks-grid .tg-drag:active { cursor: grabbing; }

/* Ownership pill */
.tasks-grid .ownership-select {
    width: 100%; padding: 6px 14px;
    border: 1.5px solid transparent; border-radius: 100px;
    font-size: 12.5px; font-weight: 700;
    font-family: inherit; cursor: pointer;
    transition: all 0.12s;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-color: #F3F1EB; color: var(--text);
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.tasks-grid .tg-row[data-own="axes"] .ownership-select {
    background-color: #FDE7E5; color: var(--c-axes); border-color: rgba(200,39,26,0.25);
}
.tasks-grid .tg-row[data-own="joint"] .ownership-select {
    background-color: #E8E9FE; color: var(--c-joint); border-color: rgba(99,102,241,0.3);
}
.tasks-grid .tg-row[data-own="client"] .ownership-select {
    background-color: #EDEFF2; color: var(--c-client); border-color: rgba(107,114,128,0.3);
}
.tasks-grid .ownership-select:hover { filter: brightness(0.95); }
.tasks-grid .ownership-select:focus {
    outline: none; border-color: currentColor;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}
.tasks-grid .ownership-select option { background: var(--surface); color: var(--text); }

/* Done checkbox */
.tasks-grid .tg-done { text-align: center; line-height: 1; }
.tasks-grid input[type="checkbox"].f-done {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 7px !important;
    border: 2.5px solid #9C9890 !important;
    background: var(--surface) !important;
    cursor: pointer;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin: 0;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.15s;
}
.tasks-grid input[type="checkbox"].f-done:hover {
    border-color: var(--c-done) !important;
    background: #F0FDF6 !important;
}
.tasks-grid input[type="checkbox"].f-done:checked {
    background: var(--c-done) !important;
    border-color: var(--c-done) !important;
}
.tasks-grid input[type="checkbox"].f-done:checked::after {
    content: '';
    position: absolute;
    left: 6px; top: 1px;
    width: 6px; height: 12px;
    border: solid #FFFFFF;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

/* Delete icon */
.tasks-grid .tg-del { text-align: center; }
.tasks-grid .icon-btn {
    background: transparent; border: none; cursor: pointer;
    width: 26px; height: 26px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: var(--text-muted);
    margin: 0 auto;
    transition: all 0.15s;
}
.tasks-grid .icon-btn:hover { background: #F3F1EB; color: var(--text); }
.tasks-grid .icon-btn.delete:hover { background: #FEF1F1; color: #C41A1A; }

/* Dimmed (filter) */
.tasks-grid .tg-row.dimmed { opacity: 0.28; }
.tasks-grid .tg-row.dimmed:hover { opacity: 0.55; }

/* ── Legend ──────────────────────── */
.cg-legend {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 8px 4px;
}
.legend-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 12px; border-radius: 100px;
    background: var(--surface); border: 1.5px solid var(--border);
    font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
    cursor: pointer; user-select: none;
    transition: all 0.15s;
}
.legend-pill:hover { border-color: var(--text-muted); color: var(--text); }
.legend-pill.active {
    background: var(--surface-2);
    border-color: var(--accent);
    color: var(--text); font-weight: 700;
    box-shadow: 0 2px 8px rgba(200,39,26,0.15);
}
.legend-dot {
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

/* ── Gantt container ──────────────── */
.gantt-container {
    padding: 16px 20px;
    overflow: auto;
    max-height: 700px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.gantt-container svg { min-width: 100%; }
.gantt .grid-header { fill: var(--surface-2); stroke: var(--border); }
.gantt .grid-row { fill: transparent; }
.gantt .grid-row:nth-child(even) { fill: #FDFBF6; }
.gantt .row-line, .gantt .tick { stroke: #EFEADF; }
/* Сегодняшний день — насыщенный индиго, контрастно с оранжевыми праздниками */
.gantt .today-highlight {
    fill: rgba(99,102,241,0.22) !important;
    stroke: rgba(99,102,241,0.85);
    stroke-width: 1.5;
}
.gantt .lower-text, .gantt .upper-text { fill: var(--text-secondary); font-weight: 600; }

.gantt .bar-wrapper.is-active .bar {
    stroke: #F59E0B; stroke-width: 2;
    filter: drop-shadow(0 0 6px rgba(245,158,11,0.5));
}
.gantt .bar-wrapper .bar { fill: var(--accent); rx: 5; }
.gantt .bar-wrapper.own-axes .bar { fill: var(--c-axes); }
.gantt .bar-wrapper.own-joint .bar { fill: var(--c-joint); }
.gantt .bar-wrapper.own-client .bar { fill: var(--c-client); }
.gantt .bar-wrapper.own-done .bar { fill: var(--c-done); opacity: 0.85; }
.gantt .bar-wrapper .bar-progress { fill: rgba(255,255,255,0.25); rx: 5; }
.gantt .bar-label {
    fill: #fff; font-weight: 600; font-size: 12px;
    letter-spacing: -0.1px;
}
.gantt .bar-label.big { fill: var(--text); }
.gantt .bar-wrapper:hover .bar { filter: brightness(1.05); }
.gantt .bar-wrapper .bar { cursor: move; }
.gantt .bar-wrapper .handle { cursor: ew-resize; }
.gantt .bar-wrapper.dimmed .bar { opacity: 0.2; }
.gantt .bar-wrapper.dimmed .bar-label { opacity: 0.4; }
.gantt .details-container {
    background: #1A1816; color: #fff; border: none;
    border-radius: 8px; padding: 10px 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.25);
    font-size: 13px; min-width: 160px;
}

/* Mode chips */
.gantt-controls {
    display: flex; gap: 4px;
    background: #F3EFE4; padding: 3px; border-radius: 100px;
}
.mode-chip {
    background: transparent; border: none;
    padding: 6px 14px; border-radius: 100px;
    font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
    cursor: pointer; font-family: inherit;
    transition: all 0.15s;
}
.mode-chip:hover { color: var(--text); }
.mode-chip.active {
    background: var(--surface); color: var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ── Holidays modal ──────────────── */
.holidays-list {
    margin-top: 12px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}
.holidays-list:empty { display: none; }
.holiday-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px; border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.holiday-row:last-child { border-bottom: none; }
.holiday-row .date {
    font-variant-numeric: tabular-nums; color: var(--text);
    width: 96px; font-weight: 600;
}
.holiday-row .label { flex: 1; color: var(--text-secondary); }
.holiday-row .rm {
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 18px;
    width: 26px; height: 26px; border-radius: 50%;
    transition: all 0.15s;
}
.holiday-row .rm:hover { background: #FEF1F1; color: #C41A1A; }

/* ── Annual Gantt (вкладка "Планируемые") ───────────── */
.planning-gantt-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    flex-wrap: wrap;
    gap: 12px;
}
.planning-gantt-head h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
#planning-gantt-host .gantt-container {
    border-radius: 0 0 12px 12px;
    border-top: none;
}
.planning-gantt-empty {
    padding: 32px 20px;
    text-align: center;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--text);
}
/* Цвета полос на Annual Gantt: planned = синий, deferred = янтарный */
.gantt .bar-wrapper.pl-stage-planned .bar { fill: #6366F1; }
.gantt .bar-wrapper.pl-stage-deferred .bar { fill: #F59E0B; }
