:root {
    /* Срочность дат — как бейджи задач в сайдбаре (просрочено / сегодня / будущее) */
    --schedule-urgency-overdue: #dc3545;
    --schedule-urgency-today: #198754;
    --schedule-urgency-future: #0dcaf0;
}

.btn-create,
.btn-edit,
.btn-delete {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-create .bi,
.btn-edit .bi,
.btn-delete .bi {
    flex-shrink: 0;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: skyblue;
}

/* Область приложения: сайдбар + прокручиваемый контент на всю ширину окна */
.main {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    flex-shrink: 0;
    align-self: stretch;
}

/* Вертикальная прокрутка только здесь — у правого края браузера */
.content {
    padding: 10px;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Планшет и телефон: колоночная раскладка, меню в аккордеоне сверху */
@media (max-width: 767.98px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow: visible;
    }

    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .mobile-header {
        flex-shrink: 0;
    }

    #navbar-mobile-menu {
        flex-shrink: 0;
        max-height: 70vh;
        overflow-y: auto;
    }

    .main {
        flex: 1 1 auto;
        flex-direction: column;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .sidebar {
        min-height: auto;
    }

    .content {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }
}
.menu-icon {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.table-row, div.link {
    transition: .3s;
}

.table-row.link, div.link {
    cursor: pointer;
    transition: .3s;
}

/* Корневая обёртка страницы: без container-fluid/py-4 — отступ только у .content */
.app-page {
    width: 100%;
    min-width: 0;
}

/* Шапка страницы: списки и карточки — заголовок h4 в одном месте и стиле */
.page-list-header {
    gap: 0.5rem;
}

.page-list-header__title {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.2;
}

.table-row:hover , div.link {
    filter: brightness(0.85);
}

.nav svg {
    width: 16px;
    height: 16px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Убираем отступы, чтобы иконка не выходила за границы */
}

.btn-icon svg {
    width: 16px; /* Устанавливаем ширину */
    height: 16px; /* Устанавливаем высоту */
}

.is-deleted {
    --bs-table-bg: lightgrey;
}

#loading-indicator {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 5px;
    z-index: 9999;
}

/* Стили для списка лидов */
.lead-list {
    display: flex;
    flex-direction: column;
}

.lead-list-header {
    display: none;
    padding: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.lead-list-item {
    display: flex;
    flex-wrap: wrap;
    padding: 0.75rem;
    border-bottom: 1px solid #dee2e6;
    gap: 0.5rem;
    transition: background-color 0.15s ease-in-out;
}

.lead-list-item:hover {
    background-color: rgba(0, 0, 0, 0.025);
}

.lead-list-item:last-child {
    border-bottom: none;
}

.lead-col-id {
    flex: 0 0 50px;
    max-width: 50px;
}

.lead-col-customer {
    flex: 2;
    min-width: 100px;
}


.lead-col-furniture-type {
    flex: 2;
    min-width: 150px;
}

.lead-col-status {
    flex: 1;
    min-width: 100px;
}

.lead-col-priority {
    flex: 1;
    min-width: 100px;
}

.lead-col-budget {
    flex: 1;
    min-width: 80px;
}

.lead-col-manager {
    flex: 1;
    min-width: 100px;
}

.lead-col-created {
    flex: 1;
    min-width: 100px;
}

@media (min-width: 768px) {
    .lead-list-header {
        display: flex;
    }

    .lead-list-item {
        flex-wrap: nowrap;
        align-items: center;
    }

    .lead-list-item:hover {
        background-color: rgba(0, 0, 0, 0.04);
        cursor: pointer;
    }
}

/* Стили для списка задач */
.task-list {
    display: flex;
    flex-direction: column;
}

.task-list-header {
    display: flex;
    padding: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.task-list-item {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #dee2e6;
    gap: 0.5rem;
    transition: background-color 0.15s ease-in-out;
}

.task-list-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
    cursor: pointer;
}

.task-list-item:last-child {
    border-bottom: none;
}

.task-col-id {
    flex: 0 0 50px;
    max-width: 50px;
}

.task-col-title {
    flex: 3;
    min-width: 150px;
}

.task-col-lead {
    flex: 1;
    min-width: 120px;
}

.task-col-status {
    flex: 1;
    min-width: 100px;
}

.task-col-priority {
    flex: 1;
    min-width: 100px;
}

.task-col-deadline {
    flex: 1;
    min-width: 100px;
}

.task-col-created {
    flex: 1;
    min-width: 100px;
}

/* Розовая строка — только открытая просроченная (класс task-overdue в шаблоне) */
.task-list-table tbody tr.task-overdue td,
.js__lead-tasks tbody tr.task-overdue td {
    background-color: #f8d7da !important;
}

.task-list-table.table-hover > tbody > tr.task-overdue:hover td,
.js__lead-tasks.table-hover > tbody > tr.task-overdue:hover td,
.js__lead-tasks tbody tr.task-overdue:hover td {
    background-color: #f5c2c7 !important;
}

.task-list-table tbody tr.task-due-today td,
.js__lead-tasks tbody tr.task-due-today td {
    background-color: rgba(25, 135, 84, 0.15) !important;
}

.task-list-table.table-hover > tbody > tr.task-due-today:hover td,
.js__lead-tasks tbody tr.task-due-today:hover td {
    background-color: rgba(25, 135, 84, 0.22) !important;
}

/* Фактическая дата завершения не в срок (неактивная задача) */
.task-date-late {
    color: var(--schedule-urgency-overdue, #dc3545) !important;
    font-weight: 600;
}

/* Стили для таблиц - уменьшенный шрифт */
table.table {
    font-size: 0.875rem;
}

table.table small {
    font-size: 0.75rem;
}

/* Удалённые эскизы: красная обводка без изменения размера */
.lead-object-image--deleted {
    opacity: 0.6;
}

.lead-object-image--deleted .js__detail-image-preview,
.lead-object-image--deleted .detail-section__file-icon {
    box-shadow: inset 0 0 0 2px #dc3545;
}

.lead-customer-file--deleted {
    opacity: 0.6;
}

.lead-customer-file--deleted .js__detail-image-preview,
.lead-customer-file--deleted .detail-section__file-icon {
    box-shadow: inset 0 0 0 2px #dc3545;
}

.lead-measuring-photo--deleted {
    opacity: 0.6;
}

.lead-measuring-photo--deleted .js__detail-image-preview {
    box-shadow: inset 0 0 0 2px #dc3545;
}

/* Имя файла под превью: не шире фото, многоточие у имени, расширение всегда видно */
.file-name-truncated {
    width: 100%;
}

.file-name-truncated__inner {
    display: flex;
    max-width: 100%;
    line-height: 1.2;
}

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

.file-name-truncated__ext {
    flex-shrink: 0;
    white-space: nowrap;
}

.detail-image-popup__stage {
    position: relative;
    display: inline-block;
    max-width: 95vw;
    max-height: 95vh;
    line-height: 0;
    cursor: default;
}

.detail-image-popup__stage .detail-section__popup-img {
    display: block;
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    object-fit: contain;
    pointer-events: none;
}

.detail-image-popup__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border-radius: 0.375rem;
    font-size: 1.75rem;
    line-height: 1;
    opacity: 0.92;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.detail-image-popup__nav--prev {
    left: 0.75rem;
}

.detail-image-popup__nav--next {
    right: 0.75rem;
}

/* Крестик удаления на превью файла: красная рамка, при наведении — красный фон и белый крест */
.file-card__remove-btn {
    --bs-btn-close-color: #dc3545;
    --bs-btn-close-opacity: 1;
    width: 1.35rem;
    height: 1.35rem;
    margin: 2px;
    padding: 0;
    opacity: 1;
    z-index: 10;
    background-color: #fff;
    border: 3px solid #dc3545 !important;
    border-radius: 0.25rem;
    background-size: 0.6em;
    box-sizing: border-box;
}

.file-card__remove-btn:hover,
.file-card__remove-btn:focus {
    --bs-btn-close-color: #fff;
    background-color: #dc3545;
    opacity: 1;
    filter: none;
    box-shadow: 0 1px 3px rgba(220, 53, 69, 0.35);
}

.directory-page {
    max-width: 600px;
    width: 100%;
}

.directory-page__list-wrap {
    border: none;
    background: transparent;
}

.directory-page__list > :not(caption) > * > * {
    border-top: none;
    border-left: none;
    border-right: none;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.directory-page__list td:first-child {
    padding-left: 0;
}

.directory-page__list {
    table-layout: fixed;
    width: 100%;
}

.directory-page__row-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 0.5rem;
}

.directory-page__actions-col {
    width: 220px;
    padding-right: 0;
    white-space: nowrap;
}

.directory-page__actions {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.35rem;
}

.directory-page__actions .btn,
.directory-page__actions-form {
    flex-shrink: 0;
}

.directory-page__actions-form {
    margin: 0;
}

.directory-page__list td:last-child {
    padding-right: 0;
}

.directory-page__list tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--bs-border-color);
}

.directory-page__list tbody tr:hover {
    background-color: transparent;
    --bs-table-hover-bg: transparent;
    --bs-table-accent-bg: transparent;
}

.directory-entry--deleted td {
    opacity: 0.65;
}

.directory-entry--deleted td:first-child {
    text-decoration: line-through;
    color: var(--bs-secondary-color);
}

.lead-offer-file--archived a {
    text-decoration: line-through;
    color: var(--bs-secondary-color) !important;
}

/* Иконка прикрепить/заменить файлы КП (ссылка-иконка, без кнопки) */
a.lead-offer-file-slot__action {
    flex-shrink: 0;
    display: inline-block;
    width: 1.125rem;
    height: 1.125rem;
    line-height: 1.125rem;
    font-size: 1.125rem;
    text-decoration: none;
    color: #0d6efd;
    cursor: pointer;
    vertical-align: middle;
}

a.lead-offer-file-slot__action:hover,
a.lead-offer-file-slot__action:focus {
    color: #0a58ca;
    opacity: 0.85;
    outline: none;
}

/* Список лидов */
.lead-index-table {
    width: 100%;
    table-layout: auto;
}

.lead-index-table__col-id {
    width: 40px;
}

.lead-index-table__col-customer {
    min-width: 150px;
    max-width: 250px;
}

.lead-index-table__col-furniture {
    min-width: 100px;
    max-width: 200px;
}

.lead-index-table__col-status,
.lead-index-table__col-priority,
.lead-index-table__col-budget,
.lead-index-table__col-created {
    width: 100px;
}

.lead-index-table__col-manager {
    width: 120px;
}

.lead-index-table__id {
    width: 40px;
    white-space: nowrap;
}

.lead-index-table__customer {
    min-width: 150px;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-index-table__furniture {
    min-width: 100px;
    max-width: 200px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
}

.lead-index-table__status,
.lead-index-table__priority,
.lead-index-table__budget,
.lead-index-table__created {
    width: 100px;
    max-width: 100px;
    font-size: 0.8125rem;
    line-height: 1.25;
    vertical-align: middle;
}

.lead-index-table__manager {
    width: 120px;
    max-width: 120px;
    font-size: 0.8125rem;
    line-height: 1.25;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lead-index-table__status-label {
    display: block;
    overflow-wrap: anywhere;
}

/* Подсветка «Следующее действие» — цвета как в меню задач / календаре */
.lead-index-table__next-action-box.lead-index-table__next-action--today,
.lead-index-table__next-action-box.lead-index-table__next-action--overdue {
    padding: 3px;
    border-radius: 3px;
}

.lead-index-table__next-action-box.lead-index-table__next-action--today {
    background-color: rgba(25, 135, 84, 0.15);
}

.lead-index-table__next-action-box.lead-index-table__next-action--overdue {
    background-color: rgba(220, 53, 69, 0.15);
}

.lead-index-table.table-hover > tbody > tr:hover .lead-index-table__next-action-box.lead-index-table__next-action--today {
    background-color: rgba(25, 135, 84, 0.22);
}

.lead-index-table.table-hover > tbody > tr:hover .lead-index-table__next-action-box.lead-index-table__next-action--overdue {
    background-color: rgba(220, 53, 69, 0.22);
}

/* Сворачиваемые блоки на странице лида */
/* Страница лида: один столбец, ширина контента = 1600 − сайдбар − полоса прокрутки */
.lead-show__stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: calc(1600px - 280px - 16px);
}

.lead-show__stack > .card {
    margin: 0;
}

.js__lead-objects .lead-object-item:last-of-type {
    margin-bottom: 0 !important;
}

.lead-show .lead-calculation-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 767.98px) {
    .lead-show__stack {
        max-width: calc(1600px - 16px);
    }
}

.lead-block__toggle {
    cursor: pointer;
    user-select: none;
}

.lead-block__chevron {
    font-size: 0.875rem;
    opacity: 0.55;
    transition: transform 0.2s ease;
}

.lead-collapsible--collapsed .lead-block__chevron {
    transform: rotate(-90deg);
}

.lead-calculation-comments tbody tr:last-child td {
    border-bottom-width: 0;
}
