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

:root {
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --dark-color: #2c3e50;
    --text-secondary: #5c6b7a;
    --light-color: #ecf0f1;
    --border-color: #ddd;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* Палитра для главной: белый + мягкий ярко-фиолетовый */
    --home-bg: #ffffff;
    --home-accent: #9b7ede;
    --home-accent-soft: rgba(155, 126, 222, 0.18);
    --home-header-bg: #f0edf5;
    --home-header-text: #3d3552;
    --home-row-alt: #faf9fc;
    --home-border: #e5e0ef;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
        Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: #f5f5f5;
}

/* Рабочая область занимает всю ширину монитора: прежнее min(90vw, 1440px)
   срезало по 5% с каждого края и упиралось в потолок 1440px, из-за чего на
   широких экранах оставались белые полосы. Отступы держим на padding, чтобы
   контент не прилипал к краям. */
.container {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 0 clamp(16px, 2vw, 40px);
}

/* Админские разделы должны использовать рабочую область, а не узкую колонку. */
#adminPage {
    width: 100%;
    overflow-x: hidden;
}

/* Дублировало прежние значения .container — держим их согласованными,
   иначе админка снова получила бы белые полосы по краям. */
#adminPage > .container {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
}

.admin-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: auto;
}

/* Навигация */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.nav-brand h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 500;
    transition: color 0.3s;
    cursor: pointer;
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: var(--dark-color);
    margin: 3px 0;
    transition: 0.3s;
}

/* Страницы */
.page {
    padding: 2rem 0;
    min-height: calc(100vh - 80px);
}

.hero {
    text-align: center;
    padding: 4rem 0;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.hero p {
    font-size: 1.2rem;
    color: #666;
}

/* Формы авторизации */
.auth-container {
    max-width: 500px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.auth-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: var(--light-color);
    cursor: pointer;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.3s;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

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

/* Кнопки */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #357abd;
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

.btn-success:hover {
    background: #3fa862;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Матрешка */
.matryoshka-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    margin-top: 2rem;
}

.step {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--light-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step h3 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.select-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a90e2' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    padding-right: 2.5rem;
}

.select-input:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.15);
}

.select-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.select-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.6;
}

.selected-path {
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.selected-path h3 {
    margin-bottom: 1rem;
}

.path-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

/* Админ-панель */
.admin-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.admin-tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: var(--light-color);
    cursor: pointer;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.3s;
}

.admin-tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.admin-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.admin-section h3 {
    margin-bottom: 1.5rem;
}

.admin-documents-hint {
    font-size: 0.88rem;
    color: var(--text-secondary, #6c757d);
    margin-bottom: 1rem;
    max-width: 48rem;
    line-height: 1.45;
}

.admin-documents-table tbody tr.admin-documents-row {
    cursor: pointer;
}

.admin-documents-table tbody tr.admin-documents-row:hover {
    background: rgba(74, 144, 226, 0.06);
}

/* Таблица «Документы»: три колонки; общие правила .data-table дают последней ячейке 120px и центрирование — ломает «Адрес». */
table.data-table.admin-documents-table {
    table-layout: auto;
}

.admin-documents-table th:first-child,
.admin-documents-table td:first-child {
    width: auto;
    min-width: 7rem;
    max-width: 10rem;
    text-align: left;
}

.admin-documents-table th:nth-child(2),
.admin-documents-table td:nth-child(2) {
    width: auto;
    min-width: 10rem;
    max-width: 26%;
    text-align: left;
}

.admin-documents-table th:last-child,
.admin-documents-table td:last-child {
    width: auto;
    min-width: 42%;
    text-align: left;
}

.summary-act-builder {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-act-header h4 {
    margin: 0 0 0.5rem;
}

.summary-act-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 1rem;
    align-items: end;
}

.summary-act-filter-actions {
    display: flex;
    align-items: end;
    gap: 0.5rem;
    grid-column: 1 / -1;
}

.summary-act-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.summary-act-selection-stats {
    color: var(--text-primary);
}

.summary-act-selection-divider {
    margin: 0 0.5rem;
    color: var(--text-secondary);
}

.summary-act-selection-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.summary-act-table th,
.summary-act-table td {
    vertical-align: top;
}

.summary-act-col-check {
    width: 88px;
    text-align: center;
}

.summary-act-address {
    font-weight: 600;
}

.summary-act-address-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.summary-act-empty {
    padding: 1rem;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    background: #fafbfc;
}

.summary-act-generate-row {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

.summary-act-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.data-table th {
    background: var(--light-color);
    font-weight: 600;
}

.data-table th:first-child,
.data-table td:first-child {
    width: 80px;
    text-align: center;
}

.data-table th:last-child,
.data-table td:last-child {
    width: 120px;
    text-align: center;
}

.data-table tr:hover {
    background: #f9f9f9;
}

/* Модальное окно */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-large {
    max-width: 800px;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: var(--dark-color);
}

/* Адаптивность */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background: white;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: var(--shadow-lg);
        padding: 2rem 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-toggle {
        display: flex;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .matryoshka-container {
        padding: 1rem;
    }

    .step {
        padding: 1rem;
    }

    .admin-tabs {
        flex-direction: column;
    }

    .admin-tab-btn {
        min-width: 120px;
    }

    .summary-act-filters {
        grid-template-columns: 1fr;
    }

    .summary-act-filter-actions,
    .summary-act-generate-row {
        justify-content: stretch;
    }

    .summary-act-filter-actions .btn,
    .summary-act-generate-row .btn {
        width: 100%;
    }

    .data-table {
        font-size: 0.9rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .auth-container {
        padding: 1.5rem;
    }

    .hero {
        padding: 2rem 0;
    }

    .hero h2 {
        font-size: 1.5rem;
    }
}

/* Утилиты */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.5rem;
}
.mt-2 {
    margin-top: 1rem;
}
.mt-3 {
    margin-top: 1.5rem;
}
.mb-1 {
    margin-bottom: 0.5rem;
}
.mb-2 {
    margin-bottom: 1rem;
}
.mb-3 {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* Страница выбора работ */
.works-selection-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    margin-top: 2rem;
}

.selection-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.selection-header h3 {
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.defect-info {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.6;
}

.works-categories-section {
    margin-bottom: 2rem;
}

.works-list-container {
    margin: 2rem 0;
}

.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.work-card {
    background: var(--light-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.work-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.15);
    transform: translateY(-2px);
}

.work-card.selected {
    border-color: var(--primary-color);
    background: #e8f4fd;
}

.work-card-checkbox {
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.work-card-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.work-card-content {
    flex: 1;
}

.work-card-content h4 {
    margin: 0 0 0.5rem 0;
    color: var(--dark-color);
    font-size: 1rem;
}

.work-price {
    margin: 0;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.selected-works-summary {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--light-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.selected-works-summary h4 {
    margin: 0 0 1rem 0;
    color: var(--dark-color);
}

.selected-works-summary h4 span {
    color: var(--primary-color);
    font-weight: 700;
}

.selected-works-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selected-work-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    gap: 1rem;
}

.selected-work-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.work-name {
    font-weight: 500;
    color: var(--dark-color);
}

.work-price-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.selected-work-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-right: 0.25rem;
}

.work-quantity-input {
    width: 70px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
}

.work-quantity-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.work-quantity-input.work-quantity-input-error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.12);
}

.works-validation-error {
    display: none;
    margin-top: 0.75rem;
    color: #c0392b;
    font-size: 0.875rem;
}

.work-materials {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.work-materials strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--dark-color);
}

.materials-list {
    margin: 0.25rem 0 0 0;
    padding-left: 1.25rem;
    list-style-type: disc;
}

.materials-list li {
    margin: 0.125rem 0;
    color: var(--text-secondary);
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.btn-remove:hover {
    background: #c0392b;
}

.empty-message {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

.works-selection-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-secondary:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* Модальное окно подтверждения */
.modal-large {
    max-width: 800px;
}

.confirmation-info {
    margin-bottom: 2rem;
}

.confirmation-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--light-color);
    border-radius: 8px;
}

.confirmation-section h4 {
    margin: 0 0 0.75rem 0;
    color: var(--dark-color);
}

.confirmation-section p {
    margin: 0.5rem 0;
    color: #666;
}

.confirmation-section ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.confirmation-section li {
    margin: 0.5rem 0;
    color: #666;
}

.confirmation-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.confirmation-actions .btn {
    min-width: 10rem;
}

@media (max-width: 600px) {
    .confirmation-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .confirmation-actions .btn {
        width: 100%;
        min-width: 0;
    }
}

/* Роутеры (хлебные крошки) */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--light-color);
    border-radius: 8px;
    font-size: 0.9rem;
}

.breadcrumb-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
    cursor: pointer;
}

.breadcrumb-link:hover {
    color: #357abd;
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #999;
}

.breadcrumb-current {
    color: var(--dark-color);
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Полная ширина */
.container-fluid {
    width: 100%;
    padding: 0;
}

.applications-table-wrap.full-width {
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
}

.card {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.details-header h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.defect-description {
    font-size: 1.1rem;
    white-space: pre-wrap;
    background: var(--home-row-alt);
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid var(--home-accent);
}

.list-group {
    list-style: none;
    padding: 0;
}

.list-group-item {
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0;
}

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

.d-flex {
    display: flex;
}
.justify-content-between {
    justify-content: space-between;
}
.align-items-center {
    align-items: center;
}
.text-muted {
    color: #6c757d;
}
.small {
    font-size: 0.85rem;
}
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}
.ml-2 {
    margin-left: 0.5rem;
}

/* Фильтры на главной */
.filters-bar {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--home-border);
    display: flex;
    gap: 2rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 200px;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.filter-input,
.filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.2s;
    width: 100%;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--home-accent);
}

/* Стилизованные селекты под цвета сайта (без дефолтного вида) */
.filter-select-styled {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--home-bg);
    border: 1px solid var(--home-border);
    color: var(--home-header-text);
    border-radius: 6px;
    padding-right: 2rem;
    cursor: pointer;
}
.filter-select-styled:hover {
    border-color: var(--home-accent);
}
.filter-select-styled:focus {
    border-color: var(--home-accent);
    box-shadow: 0 0 0 2px var(--home-accent-soft);
}
.filter-select-styled option {
    background: white;
    color: var(--dark-color);
}
/* Стрелка селекта в цветах сайта */
.filter-group .filter-select-styled {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239b7ede' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    height: 36px; /* Чтобы выровнять с инпутами */
}

/* Таблица заявок на главной */
.applications-table-wrap {
    background: var(--home-bg);
    /* border-radius: 8px;  убираем для full-width */
    /* box-shadow: var(--shadow-lg); убираем для full-width */
    border-bottom: 1px solid var(--home-border); /* только снизу */
    /* Контейнер сам себе скролл-порт по обеим осям: только так закрепляется
       шапка таблицы (sticky у th отсчитывается от ближайшего скролл-порта).
       Раньше здесь были overflow-x: auto + min-height, из-за чего порт не
       скроллился вертикально, прокручивалась страница, и заголовки уезжали.
       Высота — от фактического отступа сверху (--table-top, его выставляет
       syncTableViewportHeight в app.js): панель фильтров переносится по
       строкам, поэтому любая константа даёт либо двойной скролл, либо
       обрезанную таблицу. Значение в fallback — на случай, если скрипт не
       успел отработать. */
    overflow: auto;
    position: relative;
    max-height: calc(100vh - var(--table-top, 190px));
}

.applications-table {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.applications-table thead {
    background: var(--home-header-bg);
}

/* Шапка закреплена при прокрутке: в списке из сотен заявок и десяти колонок
   уехавшие заголовки заставляют угадывать, где «Стройконтроль», а где «Тип
   дефекта». Sticky ставим на th, а не на thead: при border-collapse: collapse
   границы у закреплённого thead в части браузеров пропадают.
   box-shadow вместо border-bottom по той же причине — collapse-границы не
   прокручиваются вместе с элементом. */
.applications-table th {
    padding: 0.55rem 0.65rem;
    text-align: left;
    font-weight: 600;
    color: var(--home-header-text);
    border-bottom: 1px solid var(--home-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--home-header-bg);
    box-shadow: inset 0 -1px 0 var(--home-border);
}

.applications-table th.col-num,
.applications-table th.col-house,
.applications-table th.col-section,
.applications-table th.col-kv,
.applications-table th.col-building {
    text-align: center;
}

.applications-table .col-project {
    max-width: 18rem;
}

.applications-table .cell-ellipsis {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.app-num-cell {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    white-space: nowrap;
    display: inline-block;
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

/* Бейджи в таблице и карточках */
.defect-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.defect-badge-warranty {
    background: rgba(56, 152, 236, 0.18);
    color: #1a5f9e;
    border: 1px solid rgba(56, 152, 236, 0.4);
}

.defect-badge-client {
    background: rgba(142, 68, 204, 0.15);
    color: #6b2fa0;
    border: 1px solid rgba(142, 68, 204, 0.35);
}

.defect-badge-category {
    background: rgba(155, 126, 222, 0.18);
    color: #4a3d6b;
    border: 1px solid rgba(155, 126, 222, 0.35);
}

.ekc-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.35;
    background: #eef1f4;
    color: #3d4f5f;
    border: 1px solid #dbe2e8;
    max-width: 100%;
}

.ekc-badge.ekc-ok {
    background: rgba(80, 200, 120, 0.12);
    color: #1e6b3a;
    border-color: rgba(80, 200, 120, 0.35);
}

.ekc-badge.ekc-warn {
    background: rgba(243, 156, 18, 0.15);
    color: #8a5a0f;
    border-color: rgba(243, 156, 18, 0.4);
}

.ekc-badge.ekc-cancel {
    background: rgba(231, 76, 60, 0.15);
    color: #922b21;
    border-color: rgba(231, 76, 60, 0.4);
}

.ekc-badge.ekc-pending {
    background: rgba(241, 196, 15, 0.2);
    color: #7d6608;
    border-color: rgba(241, 196, 15, 0.5);
}

.ekc-badge.ekc-gray {
    background: rgba(149, 165, 166, 0.2);
    color: #5a6c6e;
    border-color: rgba(149, 165, 166, 0.4);
}

.scontrol-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.scontrol-active {
    background: rgba(74, 144, 226, 0.14);
    color: #1f5f9e;
    border: 1px solid rgba(74, 144, 226, 0.35);
}

.scontrol-completed {
    background: rgba(116, 128, 140, 0.14);
    color: #53616c;
    border: 1px solid rgba(116, 128, 140, 0.3);
}

#adminAccounting { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overflow: hidden; }
#adminAccounting .accounting-import,
#adminAccounting .accounting-controls,
#adminAccounting .accounting-grid,
#adminAccounting .accounting-panel,
#adminAccounting #accountingReceiptPreview { max-width: 100%; min-width: 0; box-sizing: border-box; }
#adminAccounting .accounting-panel { overflow-x: auto; }
#adminAccounting .accounting-table { min-width: 0; max-width: 100%; }
#adminAccounting .accounting-grid > *, #adminAccounting .accounting-import-controls { min-width: 0; }
#adminAccounting .accounting-import-controls { overflow: hidden; }
#adminAccounting .accounting-import-controls input[type="file"] { width: min(100%, 22rem); }
.accounting-header { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.accounting-controls, .accounting-import-controls { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.accounting-controls { padding: 1rem; background: #f7f8fc; border: 1px solid var(--border-color); border-radius: 10px; }
.accounting-periods { display: flex; flex-wrap: wrap; gap: .35rem; }
.accounting-period-btn { border: 1px solid #cfd8e3; background: #fff; color: #3d4f5f; border-radius: 999px; padding: .38rem .65rem; cursor: pointer; }
.accounting-period-btn.active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.accounting-import { margin: 1rem 0; padding: 1rem; display: grid; gap: .75rem; }
.accounting-import p { margin: .35rem 0 0; color: var(--text-secondary); }
.accounting-import-controls .filter-input { min-width: 150px; }
.accounting-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; }
.accounting-panel { border: 1px solid var(--border-color); border-radius: 10px; overflow-x: auto; background: #fff; }
.accounting-panel h4 { margin: 0; padding: .85rem 1rem; background: #f7f8fc; color: var(--home-header-text); }
.accounting-table { margin: 0; table-layout: fixed; width: 100%; min-width: 0; }
#accountingReceiptPreview .accounting-table { min-width: 680px; }
#adminAccounting .accounting-import-controls > * { min-width: 0; max-width: 100%; }
.accounting-receipts-table th:nth-child(1), .accounting-receipts-table td:nth-child(1) { width: 42%; }
.accounting-receipts-table th:nth-child(2), .accounting-receipts-table td:nth-child(2) { width: 10%; }
.accounting-receipts-table th:nth-child(3), .accounting-receipts-table td:nth-child(3) { width: 15%; }
.accounting-receipts-table th:nth-child(4), .accounting-receipts-table td:nth-child(4), .accounting-receipts-table th:nth-child(5), .accounting-receipts-table td:nth-child(5) { width: 16.5%; text-align: right; white-space: nowrap; }
.accounting-receipts-table td:first-child { overflow-wrap: anywhere; }
.accounting-table th,
.accounting-table td { overflow-wrap: normal; word-break: normal; text-align: left; vertical-align: top; }
.accounting-table th:first-child,
.accounting-table td:first-child { width: auto; min-width: 13rem; text-align: left; }
.accounting-table th:last-child,
.accounting-table td:last-child { width: auto; min-width: 5.5rem; text-align: right; white-space: nowrap; }
.accounting-table th:nth-child(2),
.accounting-table td:nth-child(2) { width: 4.5rem; white-space: nowrap; }
.accounting-table td[colspan] { width: auto !important; text-align: center !important; }
#accountingReceiptPreview { overflow-x: auto; }
.accounting-state { padding: .75rem 1rem; border-radius: 8px; border: 1px solid transparent; }
.accounting-state-loading { background: #eef6ff; border-color: #b8d8f8; color: #245b88; }
.accounting-state-success { background: #eefaf2; border-color: #b7e3c5; color: #236b3a; }
.accounting-state-empty { background: #f7f8fa; border-color: var(--border-color); color: var(--text-secondary); }
.accounting-state-warning { background: #fff8e8; border-color: #f3d28b; color: #805b0b; }
.accounting-state-error { background: #fff0ef; border-color: #efb6b1; color: #9b3028; }
.accounting-preview-summary, .accounting-totals { display: flex; flex-wrap: wrap; gap: 1rem; padding: .75rem; background: #f7f8fc; border-radius: 8px; }
.accounting-warning, .accounting-warning-list { color: #9a6500; }
.accounting-warning-list { margin: .5rem 0; }
.accounting-contract-section { margin-top: .75rem; border-top: 1px solid var(--border-color); }
.accounting-contract-section h5 { display: flex; justify-content: space-between; gap: 1rem; margin: 0; padding: .75rem 1rem; background: #fafbfc; font-size: .95rem; }
.house-report-details summary { cursor: pointer; color: var(--primary-color); white-space: nowrap; }
.house-report-detail-item { display: grid; gap: .2rem; min-width: 220px; padding: .6rem 0; border-bottom: 1px solid var(--border-color); }
.house-report-detail-item span { font-size: .85rem; color: var(--text-secondary); }
@media (min-width: 1200px) { .accounting-grid { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); } }
@media (max-width: 768px) {
    .accounting-controls, .accounting-import-controls { align-items: stretch; flex-direction: column; }
    .accounting-grid { grid-template-columns: minmax(0, 1fr); }
    .accounting-panel { overflow: visible; }
    .accounting-table { display: block; }
    .accounting-table thead { display: none; }
    .accounting-table tbody, .accounting-table tr { display: block; }
    .accounting-table tr { padding: .65rem .8rem; border-bottom: 1px solid var(--border-color); }
    .accounting-table td { display: grid; grid-template-columns: minmax(6.5rem, 38%) 1fr; gap: .6rem; width: auto !important; min-width: 0 !important; padding: .35rem 0; text-align: left !important; white-space: normal !important; }
    .accounting-table td::before { content: attr(data-label); font-weight: 600; color: var(--text-secondary); }
    .accounting-receipts-table td:nth-child(1)::before { content: "Материал"; }
    .accounting-receipts-table td:nth-child(2)::before { content: "Ед."; }
    .accounting-receipts-table td:nth-child(3)::before { content: "Количество"; }
    .accounting-receipts-table td:nth-child(4)::before { content: "Цена"; }
    .accounting-receipts-table td:nth-child(5)::before { content: "Сумма"; }
}

/* Кастомные селекты отчёта с чекбоксами */
.report-custom-select { position: relative; width: 100%; }
.report-custom-select > select { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.report-custom-select-trigger { width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1rem; border: 2px solid var(--border-color); border-radius: 8px; background: #fff; color: var(--dark-color); cursor: pointer; text-align: left; font: inherit; }
.report-custom-select-trigger::after { content: "⌄"; color: var(--primary-color); font-weight: 700; }
.report-custom-select.open .report-custom-select-trigger { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(74,144,226,.12); }
.report-custom-select-panel { display: none; position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 5px); padding: .55rem; background: #fff; border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 12px 30px rgba(30,45,65,.18); max-height: 300px; overflow: auto; }
.report-custom-select.open .report-custom-select-panel { display: block; }
.report-custom-select-search { width: 100%; box-sizing: border-box; padding: .6rem .7rem; margin-bottom: .45rem; border: 1px solid var(--border-color); border-radius: 7px; }
.report-custom-select-all { display: flex; align-items: center; gap: .55rem; padding: .55rem .4rem; border-bottom: 1px solid #edf0f4; font-weight: 600; cursor: pointer; }
.report-custom-select-option { display: flex; align-items: flex-start; gap: .6rem; padding: .55rem .4rem; border-radius: 6px; cursor: pointer; line-height: 1.3; }
.report-custom-select-option:hover, .report-custom-select-all:hover { background: #f3f7fc; }
.report-custom-select-option input, .report-custom-select-all input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--primary-color); flex: 0 0 auto; }
.report-custom-select.is-disabled { opacity: .55; pointer-events: none; }
@media (max-width: 700px) { .report-custom-select-panel { position: fixed; left: 5vw; right: 5vw; top: 20vh; max-height: 60vh; } }

.overdue-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.overdue-badge.overdue-ok {
    background: rgba(80, 200, 120, 0.15);
    color: #1e6b3a;
}

.overdue-badge.overdue-warn {
    background: rgba(243, 156, 18, 0.2);
    color: #8a5a0f;
}

.overdue-badge.overdue-danger {
    background: rgba(231, 76, 60, 0.18);
    color: #922b21;
}

.overdue-badge.overdue-today {
    background: rgba(74, 144, 226, 0.15);
    color: #2a5a9e;
}

/* Сортируемые заголовки таблицы */
.applications-table th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1.5rem;
}
.applications-table th.sortable:hover {
    color: var(--home-accent);
}
.applications-table th.sortable .sort-arrow {
    display: inline-block;
    margin-left: 0.25rem;
    width: 8px;
    height: 12px;
    opacity: 0.5;
    vertical-align: middle;
    transition: opacity 0.2s;
}
.applications-table th.sortable:hover .sort-arrow {
    opacity: 0.8;
}
.applications-table th.sortable .sort-arrow::before {
    content: "";
    display: block;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid var(--home-header-text);
    margin-bottom: 2px;
}
.applications-table th.sortable .sort-arrow::after {
    content: "";
    display: block;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--home-header-text);
}
.applications-table th.sortable .sort-arrow.asc::before {
    border-bottom-color: var(--home-accent);
}
.applications-table th.sortable .sort-arrow.asc::after {
    border-top-color: transparent;
}
.applications-table th.sortable .sort-arrow.desc::before {
    border-bottom-color: transparent;
}
.applications-table th.sortable .sort-arrow.desc::after {
    border-top-color: var(--home-accent);
}

.applications-table td {
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid var(--home-border);
    color: var(--dark-color);
    vertical-align: middle;
}

.applications-table tbody tr {
    background: var(--home-bg);
    transition: background 0.15s ease;
    cursor: pointer;
}

.applications-table tbody tr:nth-child(even) {
    background: var(--home-row-alt);
}

.applications-table tbody tr:hover {
    background: var(--home-accent-soft);
}

.applications-table tbody tr.selected {
    background: var(--home-accent-soft);
    outline: 1px solid var(--home-accent);
    outline-offset: -1px;
}

/* Главная: карточки строк на узких экранах */
@media (max-width: 1024px) {
    .filters-bar {
        padding: 1rem;
        gap: 1rem;
    }
    .filter-group {
        min-width: calc(50% - 0.5rem);
        flex: 1 1 140px;
    }
}

@media (max-width: 900px) {
    .applications-table thead {
        display: none;
    }
    /* Карточный режим: шапка скрыта, закреплять нечего. Сбрасываем и
       max-height, и overflow целиком — иначе внутри остался бы лишний
       вертикальный скролл, а страница не прокручивалась бы привычно.
       overflow-x одного мало: при overflow-y: auto браузер всё равно
       пересчитал бы overflow-x в auto. */
    .applications-table-wrap {
        overflow: visible;
        max-height: none;
    }
    .applications-table {
        min-width: 0;
        width: 100%;
        display: block;
    }
    .applications-table tbody {
        display: block;
    }
    .applications-table tbody tr {
        display: block;
        margin: 0.75rem 1rem 1rem;
        border: 1px solid var(--home-border);
        border-radius: 14px;
        background: var(--home-bg);
        box-shadow: 0 2px 8px rgba(61, 53, 82, 0.06);
        overflow: hidden;
    }
    .applications-table tbody tr:nth-child(even) {
        background: var(--home-bg);
    }
    .applications-table tbody td {
        display: grid;
        grid-template-columns: minmax(7.25rem, 36%) 1fr;
        gap: 0.35rem 0.75rem;
        align-items: start;
        text-align: left !important;
        padding: 0.65rem 1rem;
        border-bottom: 1px solid var(--home-border);
        font-size: 0.88rem;
    }
    .applications-table tbody td:last-child {
        border-bottom: none;
    }
    .applications-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-secondary);
        line-height: 1.4;
        padding-top: 0.12rem;
    }
    .applications-table .col-project .cell-ellipsis {
        -webkit-line-clamp: 4;
    }
    .applications-table tbody td.col-num {
        background: var(--home-header-bg);
        font-size: 1rem;
    }
    .applications-table tbody td.col-num::before {
        color: var(--home-header-text);
    }
}

.applications-table td.col-num,
.applications-table td.col-house,
.applications-table td.col-section,
.applications-table td.col-kv,
.applications-table td.col-building {
    text-align: center;
}

.app-num-with-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.ticket-refusal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.ticket-refusal-dot--red {
    background: #e03131;
}

.ticket-refusal-dot--gray {
    background: #adb5bd;
}

.applications-table-loading,
.applications-table-empty,
.applications-table-error {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

.applications-table-error {
    color: var(--danger-color);
    padding: 1rem;
    text-align: center;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--home-border);
    border-top-color: var(--home-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

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

/* Страница «Действия» — лента активности */
.actions-title {
    margin-bottom: 1.25rem;
    color: var(--home-header-text);
    font-size: 1.5rem;
}

/* Фильтры на странице «Действия» — в одном стиле с главной */
.actions-filters-bar {
    background: var(--home-bg);
    padding: 1rem 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--home-border);
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.actions-filters-bar .filter-group {
    min-width: 160px;
}
.actions-filters-bar .filter-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}
.actions-filter-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--home-bg);
    border: 1px solid var(--home-border);
    color: var(--home-header-text);
    border-radius: 6px;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    min-height: 38px;
}
.actions-filter-select:hover {
    border-color: var(--home-accent);
}
.actions-filter-select:focus {
    outline: none;
    border-color: var(--home-accent);
    box-shadow: 0 0 0 2px var(--home-accent-soft);
}
.actions-filters-bar .filter-group .actions-filter-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239b7ede' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
}
.actions-filters-bar .btn-secondary.btn-sm {
    height: 38px;
}

.activity-feed {
    position: relative;
    min-height: 120px;
}

.activity-feed-loading,
.activity-feed-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    color: var(--home-header-text);
}

.activity-feed-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-feed-item {
    background: var(--home-bg);
    border: 1px solid var(--home-border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    transition:
        box-shadow 0.2s,
        border-color 0.2s;
}

.activity-feed-item:hover {
    border-color: var(--home-accent);
    box-shadow: 0 2px 8px var(--home-accent-soft);
}

.activity-feed-item-text {
    font-size: 1rem;
    color: var(--dark-color);
    line-height: 1.4;
}

.activity-feed-item-time {
    font-size: 0.8rem;
    color: var(--home-header-text);
    margin-top: 0.35rem;
    opacity: 0.85;
}

.activity-feed-download {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--home-accent);
    text-decoration: none;
    font-weight: 500;
}

.activity-feed-download:hover {
    text-decoration: underline;
}

.activity-feed-view {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--home-accent);
    text-decoration: none;
    font-weight: 500;
}
.activity-feed-view:hover {
    text-decoration: underline;
}
.activity-feed-item .activity-feed-download + .activity-feed-view,
.activity-feed-item .activity-feed-view + .activity-feed-download {
    margin-left: 1rem;
}

/* Модалка «Изменение работ» */
.activity-works-modal-content {
    max-width: 480px;
}
.activity-works-modal-title {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    color: var(--dark-color);
}
.activity-works-section {
    margin-bottom: 1rem;
}
.activity-works-section strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--home-header-text);
    font-size: 0.95rem;
}
.activity-works-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--dark-color);
    font-size: 0.95rem;
    line-height: 1.5;
}
.activity-works-empty {
    margin: 0;
    color: var(--home-header-text);
    font-size: 0.95rem;
}
.activity-works-modal-actions {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--home-border);
}
.activity-works-modal-actions .btn {
    width: 100%;
}

@media (max-width: 768px) {
    .actions-title {
        font-size: 1.25rem;
    }
    .activity-feed-item {
        padding: 0.85rem 1rem;
    }
    .activity-feed-item-text {
        font-size: 0.95rem;
    }
    .activity-feed-download,
    .activity-feed-view {
        display: block;
        margin-left: 0 !important;
    }
    .activity-works-modal-content {
        width: 95%;
        padding: 1.25rem;
    }
    .activity-works-modal-title {
        font-size: 1.1rem;
    }
    .activity-works-list {
        padding-left: 1rem;
        font-size: 0.9rem;
    }
}

/* ==================== Модалка выбора договора ==================== */
.contract-select-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contract-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary, #f5f7fa);
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.contract-select-btn:hover {
    border-color: var(--primary, #4f46e5);
    background: #eef2ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.contract-select-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary, #1e293b);
}

.contract-select-count {
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
    background: var(--bg-primary, #fff);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    white-space: nowrap;
}

/* ==================== Заголовок работ договора ==================== */
.contract-works-header {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-radius: 10px;
    border-left: 4px solid var(--primary, #4f46e5);
}

.contract-works-header h4 {
    margin: 0;
    color: var(--primary, #4f46e5);
    font-size: 0.95rem;
}

/* ==================== Материалы в карточке работы ==================== */
.work-card-materials {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
}

.work-card-materials ul {
    margin: 0.25rem 0 0 1rem;
    padding: 0;
    list-style: disc;
}

.work-card-materials li {
    margin-bottom: 0.15rem;
    color: var(--text-secondary, #64748b);
}

/* Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e2e8f0);
    border-top-color: var(--primary, #4f46e5);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

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

/* ==================== Админка: договора ==================== */
.contract-import-form {
    background: var(--bg-secondary, #f5f7fa);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e2e8f0);
}

.contract-import-form h4 {
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.card {
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.mb-3 {
    margin-bottom: 1rem;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

/* ========== Карточка заявки (детали) ========== */
.page-ticket-detail {
    padding: 1.25rem 0 2.5rem;
    background: linear-gradient(180deg, #f8f6fc 0%, #f5f5f5 220px);
}

.container-ticket-detail {
    max-width: 920px;
}

.btn-back-ticket {
    background: white;
    border: 1px solid var(--home-border);
    color: var(--home-header-text);
}

.details-header-modern {
    border: 1px solid var(--home-border);
    border-radius: 14px;
    background: white;
    box-shadow: 0 2px 12px rgba(61, 53, 82, 0.07);
}

.details-header-modern .details-header-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.details-header-modern h2 {
    font-size: 1.45rem;
    margin: 0 0 0.35rem 0;
    color: var(--home-header-text);
}

.details-address-line {
    margin: 0;
    font-size: 0.95rem;
    color: var(--dark-color);
    line-height: 1.45;
}

.details-contract-line {
    margin: 0.5rem 0 0 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.details-contract-line:empty {
    display: none;
}

.details-header-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.ticket-header-chip {
    display: inline-flex;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: var(--home-accent-soft);
    color: #4a3d6b;
    border: 1px solid rgba(155, 126, 222, 0.35);
}

.ticket-defect-card {
    border-radius: 14px;
    border: 1px solid var(--home-border);
}

.defect-header-summary {
    margin-bottom: 1rem;
}

.defect-badges-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.ticket-private-card {
    padding: 1.15rem 1.25rem;
    border-radius: 12px;
    background: linear-gradient(
        135deg,
        rgba(155, 126, 222, 0.08) 0%,
        rgba(74, 144, 226, 0.06) 100%
    );
    border: 1px solid rgba(155, 126, 222, 0.22);
}

.ticket-refusal-text {
    margin: 0 0 0.75rem 0;
    color: #c92a2a;
    font-size: 0.92rem;
    font-weight: 700;
}

.ticket-private-title {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--home-header-text);
    letter-spacing: 0.01em;
}

.defect-description-prominent {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    line-height: 1.55;
}

.ticket-contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1.25rem;
}

.ticket-contact-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ticket-contact-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.ticket-contact-value {
    font-size: 0.95rem;
    color: var(--dark-color);
    word-break: break-word;
}

.client-phone-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.client-phone-link:hover {
    text-decoration: underline;
}

.defect-note-in-card {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(155, 126, 222, 0.35);
}

.defect-note-in-card .defect-note-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.defect-note-body {
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--dark-color);
    white-space: pre-wrap;
}

.defect-sep {
    margin: 1.25rem 0;
    border: none;
    border-top: 1px solid var(--home-border);
}

@media (max-width: 600px) {
    .ticket-contact-grid {
        grid-template-columns: 1fr;
    }
    .details-header-modern .details-header-top {
        flex-direction: column;
    }
    .container-ticket-detail {
        padding-left: 14px;
        padding-right: 14px;
    }
}

/* Кнопки формата наряда (Word / Excel) */
.narad-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.narad-format-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--home-row-alt, #f7f5ff);
    border: 1px solid var(--border-color, #e0daf5);
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
}

.narad-format-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary, #6c757d);
    white-space: nowrap;
    margin-right: 0.15rem;
}

.btn-narad-format {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    border-radius: 6px;
    min-width: 64px;
}

.btn-excel {
    background: #1d6f42;
    color: #fff;
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 64px;
}

.btn-excel:hover {
    background: #155232;
}

.btn-excel:active {
    background: #0f3b24;
}

/* Бейджи вида договора в админ-таблице «Договора» */
.contract-kind-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.contract-kind-standard {
    background: #e5edff;
    color: #1d4ed8;
    border: 1px solid #c7d2fe;
}

.contract-kind-special {
    background: #fff4e0;
    color: #b45309;
    border: 1px solid #fcd9a2;
}

/* Оверлей начальной загрузки (пока идёт проверка авторизации) */
.app-init-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--home-bg, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.2s ease;
}

.app-init-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.app-init-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--home-border, #e0e0e0);
    border-top-color: var(--home-accent, #9b7ede);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==============================================
   Модуль «Схема помещения» (scheme)
   ============================================== */

.scheme-block {
    margin: 1rem 0;
}

.scheme-block-placeholder {
    margin: 0.5rem 0;
}

/* Кнопка «Показать схему» (collapsible на главной) */
.scheme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #f0edf5, #e8e4f0);
    color: var(--home-header-text, #3d3552);
    border: 1px solid var(--home-border, #e5e0ef);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
}

.scheme-toggle-btn:hover {
    background: linear-gradient(135deg, #e8e4f0, #ddd8e8);
    border-color: var(--home-accent, #9b7ede);
    box-shadow: 0 2px 8px rgba(155, 126, 222, 0.15);
}

.scheme-toggle-btn--open {
    background: linear-gradient(135deg, #e0daf0, #d5cee8);
    border-color: var(--home-accent, #9b7ede);
}

.scheme-toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

/* Контент схемы */
.scheme-content {
    margin-top: 1rem;
    padding: 1.25rem;
    background: white;
    border-radius: 10px;
    border: 1px solid var(--home-border, #e5e0ef);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    animation: schemeSlideDown 0.3s ease-out;
}

@keyframes schemeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scheme-section-title {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dark-color, #2c3e50);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Секция изображения */
.scheme-image-section {
    margin-bottom: 1.25rem;
}

.scheme-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color, #ddd);
}

.scheme-image {
    display: block;
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 10px;
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.scheme-image:hover {
    transform: scale(1.01);
}

.scheme-image-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.scheme-image-wrapper:hover .scheme-image-delete-btn {
    opacity: 1;
}

.scheme-image-delete-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

/* Загрузка фото */
.scheme-image-upload-label {
    display: block;
    cursor: pointer;
}

.scheme-image-input {
    display: none;
}

.scheme-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    border: 2px dashed var(--border-color, #ddd);
    border-radius: 10px;
    background: #fafafa;
    color: var(--text-secondary, #5c6b7a);
    font-size: 0.9rem;
    transition: all 0.25s ease;
}

.scheme-image-placeholder:hover {
    border-color: var(--primary-color, #4a90e2);
    background: #f5f8ff;
    color: var(--primary-color, #4a90e2);
}

.scheme-upload-icon {
    font-size: 2rem;
}

.scheme-no-image {
    color: var(--text-secondary, #5c6b7a);
    font-style: italic;
    font-size: 0.85rem;
    margin: 0;
}

/* Строки расчётов */
.scheme-calc-section {
    margin-top: 1rem;
}

.scheme-calc-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.scheme-calc-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--light-color, #ecf0f1);
    border-radius: 8px;
    border: 1px solid var(--border-color, #ddd);
    transition: all 0.2s ease;
}

.scheme-calc-row:hover {
    border-color: var(--primary-color, #4a90e2);
    box-shadow: 0 1px 4px rgba(74, 144, 226, 0.1);
}

.scheme-calc-row--confirmed {
    background: #f8f9fa;
    border: 1px solid var(--border-color, #ddd);
    cursor: default;
}

.scheme-calc-row--confirmed:hover {
    border-color: var(--border-color, #ddd);
    box-shadow: none;
}

.scheme-calc-name-input {
    flex: 0 0 200px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    background: white;
    transition: border-color 0.2s;
}

.scheme-calc-name-input:focus {
    outline: none;
    border-color: var(--primary-color, #4a90e2);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.scheme-calc-expr-input {
    flex: 1;
    min-width: 120px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: "Courier New", monospace;
    background: white;
    transition: border-color 0.2s;
}

.scheme-calc-expr-input:focus {
    outline: none;
    border-color: var(--primary-color, #4a90e2);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.scheme-calc-result-display {
    flex: 0 0 auto;
    min-width: 70px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-color, #50c878);
    font-family: "Courier New", monospace;
    white-space: nowrap;
}

.scheme-calc-row-name {
    flex: 0 0 200px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dark-color, #2c3e50);
}

.scheme-calc-row-result {
    flex: 1;
    font-size: 0.85rem;
    font-family: "Courier New", monospace;
    color: var(--text-secondary, #5c6b7a);
}

.scheme-calc-delete-btn {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    background: transparent;
    color: #999;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.scheme-calc-delete-btn:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color, #e74c3c);
}

/* Кнопка добавления строки */
.scheme-add-row-btn {
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: transparent;
    border: 2px dashed var(--border-color, #ddd);
    border-radius: 8px;
    color: var(--text-secondary, #5c6b7a);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scheme-add-row-btn:hover {
    border-color: var(--primary-color, #4a90e2);
    color: var(--primary-color, #4a90e2);
    background: rgba(74, 144, 226, 0.04);
}

/* Кнопки подтвердить / редактировать */
.scheme-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.75rem;
}

.scheme-confirm-btn,
.scheme-edit-btn {
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
}

/* Загрузка */
.scheme-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--text-secondary, #5c6b7a);
    font-size: 0.875rem;
}

/* Полноэкранный просмотр */
.scheme-image-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    cursor: pointer;
}

.scheme-image-fullscreen img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.scheme-fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    backdrop-filter: blur(4px);
}

.scheme-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Контейнер схемы на странице выбора работ */
.works-scheme-container {
    margin-bottom: 1.5rem;
}

/* Адаптивность для схемы */
@media (max-width: 768px) {
    .scheme-calc-row {
        flex-wrap: wrap;
    }

    .scheme-calc-name-input {
        flex: 1 1 100%;
    }

    .scheme-calc-expr-input {
        flex: 1 1 calc(100% - 100px);
    }

    .scheme-calc-result-display {
        min-width: 60px;
    }

    .scheme-calc-row-name {
        flex: 1 1 100%;
        margin-bottom: 0.25rem;
    }

    .scheme-content {
        padding: 0.75rem;
    }

    .scheme-image {
        max-height: 250px;
    }
}
