:root {
    --page-max: 1200px;
    --bs-font-sans-serif: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-font-monospace: 'Roboto Mono', ui-monospace, 'Cascadia Code', monospace;
}

body {
    font-family: var(--bs-font-sans-serif);
}

.user-avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.user-avatar--initials {
    border-radius: 50%;
    background: #6c757d;
    color: #fff;
    font-weight: 600;
    font-size: calc(var(--avatar-size, 40px) * 0.38);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    user-select: none;
}

.navbar .user-avatar,
.navbar .user-avatar--initials {
    border: 2px solid rgba(255, 255, 255, 0.35);
}

@media (max-width: 991.98px) {
    #mainNav.navbar-collapse {
        align-items: center;
        padding: 0.75rem 0 1.25rem;
    }

    #mainNav .navbar-nav {
        align-items: center;
        width: 100%;
        max-width: 20rem;
        margin-left: auto !important;
        margin-right: auto !important;
        gap: 0.375rem;
    }

    #mainNav .navbar-nav + .navbar-nav {
        margin-top: 0.35rem;
        padding-top: 0.75rem;
        border-top: 1px solid rgba(255, 255, 255, 0.22);
    }

    #mainNav .nav-item {
        width: 100%;
    }

    #mainNav .nav-link,
    #mainNav .theme-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 2.45rem;
        text-align: center;
        font-size: 1rem;
        font-weight: 500;
        padding: 0.45rem 1rem;
        border-radius: 0.625rem;
        border: 1px solid rgba(255, 255, 255, 0.35);
        background: rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.95) !important;
        text-decoration: none;
    }

    #mainNav .nav-link:hover,
    #mainNav .nav-link:focus,
    #mainNav .theme-toggle:hover,
    #mainNav .theme-toggle:focus {
        background: rgba(255, 255, 255, 0.2);
        color: #fff !important;
    }

    #mainNav .nav-link.active {
        background: #fff;
        color: var(--bs-primary) !important;
        border-color: #fff;
        font-weight: 600;
    }

    #mainNav .theme-toggle {
        width: 100%;
    }

    #mainNav .nav-logout-form {
        width: 100%;
        margin: 0;
    }

    #mainNav .nav-logout-form button {
        border: 1px solid rgba(255, 255, 255, 0.35);
        text-decoration: none;
    }
}

body {
    background: var(--app-body-bg, #f4f6f9);
    min-height: 100vh;
}

[data-bs-theme="dark"] {
    --app-body-bg: #1a1d20;
    --app-surface-border: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="light"] {
    --app-body-bg: #f4f6f9;
    --app-surface-border: rgba(0, 0, 0, 0.125);
}

main.container {
    max-width: var(--page-max);
}

.page-header .btn {
    white-space: nowrap;
}

.part-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.part-thumb--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    font-size: 1.5rem;
}

.part-card {
    transition: box-shadow 0.15s ease;
    overflow: hidden;
    min-width: 0;
}

.part-card:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
}

.part-card .card-body {
    min-width: 0;
}

.part-card__info {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
}

.part-card .card-title {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.35;
}

.part-card .card-text {
    overflow-wrap: anywhere;
}

.part-photo-preview {
    display: inline-block;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    cursor: zoom-in;
    line-height: 0;
}

.part-photo-preview:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.part-photo-preview__img {
    display: block;
    max-width: min(100%, 220px);
    max-height: 220px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.12);
}

.part-description {
    overflow-x: auto;
}

.part-description img {
    max-width: 100%;
    height: auto;
}

#partsTable .col-qty {
    width: 5rem;
}

#partsTable .col-price {
    width: 6.5rem;
}

.part-picker {
    position: relative;
    min-width: 10rem;
}

.equipment-picker {
    position: relative;
}

.equipment-picker-hint {
    display: block;
    font-size: 0.8rem;
    margin-top: 0.25rem;
    min-height: 1.15rem;
    line-height: 1.35;
    white-space: pre-line;
}

.equipment-picker-hint.d-none {
    visibility: hidden;
    display: block !important;
}

.counter-reading-wrap--locked input {
    pointer-events: none;
    background-color: var(--bs-secondary-bg);
}

.equipment-picker-option .part-picker-option-name {
    margin-right: 0;
}

.equipment-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .equipment-toolbar__filter-field .form-select,
    .equipment-toolbar__filter-field .client-filter-picker-search {
        min-height: calc(1.5em + 0.75rem + 2px);
    }

    .equipment-toolbar__filter-field .client-filter-picker-hint,
    .equipment-toolbar__filter-spacer {
        display: block;
        min-height: 1.15rem;
        margin-top: 0.25rem;
        font-size: 0.8rem;
        line-height: 1.15;
    }

    .equipment-toolbar__filter-field .client-filter-picker-hint.d-none {
        visibility: hidden;
    }

    .equipment-toolbar__filter-spacer {
        visibility: hidden;
    }
}

.part-picker-dropdown {
    position: fixed;
    z-index: 1080;
    min-width: 18rem;
    max-width: min(28rem, calc(100vw - 1.5rem));
    max-height: min(20rem, 55vh);
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: 0.35rem 0;
    background: #fff;
    border: 2px solid #0d6efd;
    border-radius: 0.5rem;
    box-shadow:
        0 0.75rem 2rem rgba(0, 0, 0, 0.18),
        0 0.25rem 0.5rem rgba(13, 110, 253, 0.15);
}

.part-picker-dropdown .list-group-item {
    border-left: none;
    border-right: none;
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    line-height: 1.35;
    color: #212529;
    background: #fff;
}

.part-picker-dropdown .list-group-item:first-child {
    border-top: none;
}

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

.part-picker-dropdown .part-picker-option:hover,
.part-picker-dropdown .part-picker-option:focus {
    background: #e8f2ff;
    color: #0a58ca;
    z-index: 1;
}

.part-picker-dropdown .part-picker-option-name {
    display: block;
    font-weight: 600;
    margin-right: 4.5rem;
    word-break: break-word;
}

.part-picker-dropdown .badge {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35em 0.55em;
}

.part-picker-dropdown .part-picker-empty {
    padding: 0.85rem 1rem;
    color: #6c757d;
    font-size: 0.9rem;
    background: #fff;
}

.part-picker-stock {
    display: block;
    font-size: 0.75rem;
    margin-top: 0.2rem;
    min-height: 2.2rem;
    line-height: 1.35;
    white-space: pre-line;
}

.part-picker-stock.d-none {
    visibility: hidden;
    display: block !important;
}

#partsTable tbody td {
    vertical-align: top;
}

@media (max-width: 575.98px) {
    #partsTable thead {
        display: none;
    }

    #partsTable tbody tr {
        display: block;
        border-bottom: 1px solid #dee2e6;
        padding: 0.75rem 0.5rem;
    }

    #partsTable tbody td {
        display: block;
        border: none;
        padding: 0.25rem 0.5rem;
    }

    #partsTable tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: #6c757d;
        display: block;
        margin-bottom: 0.15rem;
    }
}

.list-empty {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}

.activity-log__message {
    line-height: 1.5;
    word-break: break-word;
}

.activity-log__link {
    font-weight: 500;
    text-decoration: none;
}

.activity-log__link:hover {
    text-decoration: underline;
}

#partsTable tr.part-row--invalid td {
    background-color: rgba(220, 53, 69, 0.06);
}

.part-row-error {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.comment-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.comment-photo-thumb {
    display: block;
    padding: 0;
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #fff;
    cursor: zoom-in;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.comment-photo-thumb:hover {
    border-color: #0d6efd;
    transform: scale(1.03);
}

.comment-photo-thumb img {
    width: 88px;
    height: 88px;
    object-fit: cover;
    display: block;
}

.comment-photos-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.comment-photos-preview__item {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 0.4rem;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

.comment-photos-preview__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comment-photo-modal-body {
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.comment-photo-modal-img {
    max-height: min(75vh, 720px);
    width: auto;
}

.comment-photo-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #212529;
    font-size: 1.35rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.35);
    transition: background 0.15s ease, transform 0.15s ease;
}

.comment-photo-nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.06);
}

.comment-photo-nav--prev {
    left: 0.5rem;
}

.comment-photo-nav--next {
    right: 0.5rem;
}

@media (max-width: 575.98px) {
    .comment-photo-nav {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.1rem;
    }

    .comment-photo-nav--prev {
        left: 0.25rem;
    }

    .comment-photo-nav--next {
        right: 0.25rem;
    }
}

.theme-toggle {
    border: none;
    text-decoration: none;
    line-height: 1;
}

.theme-toggle__icon {
    font-size: 1.15rem;
}

[data-bs-theme="dark"] .part-picker-dropdown {
    background: var(--bs-body-bg);
    border-color: var(--bs-primary);
    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.45);
}

[data-bs-theme="dark"] .part-picker-dropdown .list-group-item,
[data-bs-theme="dark"] .part-picker-dropdown .part-picker-empty {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .part-picker-dropdown .part-picker-option:hover,
[data-bs-theme="dark"] .part-picker-dropdown .part-picker-option:focus {
    background: rgba(13, 110, 253, 0.2);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .part-thumb--empty {
    background: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .comment-photo-thumb {
    background: var(--bs-body-bg);
    border-color: var(--app-surface-border);
}

[data-bs-theme="dark"] .comment-photos-preview__item {
    border-color: var(--app-surface-border);
}

[data-bs-theme="dark"] #partsTable tbody tr {
    border-bottom-color: var(--app-surface-border);
}

[data-bs-theme="dark"] .part-card {
    background-color: var(--bs-body-bg);
    border-color: var(--app-surface-border);
}

[data-bs-theme="dark"] .part-card:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.35);
}

/* Пустая область строки «Ответственный» — клик в ремонт (stretched-link); только ссылка — на сотрудника */
.repair-assigned-wrap {
    pointer-events: none;
}

.repair-assigned-link {
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

.repair-assigned-link:hover span:last-child {
    text-decoration: underline;
}

.repair-list-badges,
.repair-list-costs {
    font-size: 0.9375rem;
    line-height: 1.45;
}

.repair-list-badges .badge,
.repair-list-costs .badge {
    font-size: 0.875rem;
    padding: 0.4em 0.7em;
    font-weight: 500;
}

.repair-list-costs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.repair-list-filters-row {
    --bs-gutter-y: 0.75rem;
}

.repair-list-filters-checks-wrap {
    display: flex;
    justify-content: flex-start;
    width: 100%;
}

.repair-list-filters-checks {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
    width: 100%;
}

.repair-list-filter-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0;
    text-align: left;
}

.repair-list-filter-check__label {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    cursor: pointer;
    user-select: none;
}

.repair-list-filter-check__input {
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
}

@media (min-width: 992px) {
    .repair-list-filters-row .repair-list-filters-checks-wrap {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

.repair-log__message {
    line-height: 1.45;
    word-break: break-word;
}

.repair-log__type {
    font-weight: 500;
}

#repairLogsModal .modal-body {
    max-height: min(60vh, 480px);
    overflow-y: auto;
}

.repair-list-date-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
}

.repair-list-date-divider::before,
.repair-list-date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: var(--bs-border-color);
}

.repair-list-date-divider__label {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    background-color: var(--bs-tertiary-bg);
}

[data-bs-theme="light"] #listContainer .repair-list-date-divider {
    background-color: #dddddd;
}

/* Список на главной — bg-white; подписи дат в тёмной теме — тёмная «таблетка», светлый текст. */
[data-bs-theme="dark"] #listContainer .repair-list-date-divider {
    background-color: gray;
}

[data-bs-theme="dark"] #listContainer .repair-list-date-divider__label {
    color: #e9ecef;
    background-color: #343a40;
}

[data-bs-theme="dark"] #listContainer .repair-list-date-divider::before,
[data-bs-theme="dark"] #listContainer .repair-list-date-divider::after {
    background-color: #495057;
}

.counter-chart-wrap {
    position: relative;
    height: 360px;
}

.pwa-install-banner {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    z-index: 1080;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    background: #212529;
    color: #fff;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.35);
}

.pwa-install-banner__title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.pwa-install-banner__text {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.pwa-install-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
