/* Шапка сайта остаётся на месте, пока страница прокручивается. */

.navbar {
    position: sticky;
    top: 0;
}

/* Общая колонка разделов: учёт и склад. */

.pane-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.pane-layout.is-collapsed {
    grid-template-columns: minmax(0, 1fr);
}

.pane-layout.is-collapsed .pane-side {
    display: none;
}

.pane-layout:not(.is-collapsed) .pane-reveal {
    display: none;
}

.pane-main {
    min-width: 0;
}

.pane-side > .card-body {
    max-height: calc(100vh - 160px);
    overflow: auto;
}

.pane-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
}

.pane-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: inherit;
}

.pane-item.is-active {
    background: rgba(13, 110, 253, 0.12);
}

.pane-section,
.acc-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.pane-section:hover,
.acc-section-title:hover {
    background: rgba(0, 0, 0, 0.05);
}

.acc-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.acc-node:hover {
    background: rgba(0, 0, 0, 0.05);
}

.acc-node.active {
    background: rgba(13, 110, 253, 0.12);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.red { background: #dc3545; }
.dot.green { background: #198754; }
.dot.gray { background: #adb5bd; }

.acc-caret {
    width: 18px;
    display: inline-flex;
    justify-content: center;
    opacity: 0.65;
}

.acc-node:hover .acc-caret {
    opacity: 1;
}

.acc-table th,
.acc-table td {
    vertical-align: middle;
}

.pane-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 10px;
    color: inherit;
    text-decoration: none;
}

.pane-history-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: inherit;
}

@media (max-width: 992px) {
    .pane-layout:not(.is-collapsed) {
        grid-template-columns: 1fr;
    }
}

/* На широком экране колонка и таблица прокручиваются сами,
   шапка сайта и заголовки карточек остаются на месте. */

@media (min-width: 993px) {
    body:has(.pane-layout) main.container {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .pane-layout {
        height: calc(100vh - 60px - 1.5rem - 52px);
        margin-bottom: 0 !important;
        align-items: stretch;
        grid-template-rows: minmax(0, 1fr);
    }

    .pane-layout > .card {
        min-height: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .pane-side > .card-body,
    .pane-main > .card-body {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow: auto;
    }
}

/* Склад: таблица и фильтр владельца. */

.storage-main > .card-body {
    max-height: calc(100vh - 220px);
    overflow: auto;
    padding: 0;
}

@media (min-width: 993px) {
    .pane-layout > .pane-side > .card-body,
    .pane-layout > .pane-main > .card-body {
        max-height: none;
    }
}

.pane-main .table-responsive {
    overflow: visible;
}

.pane-main .table {
    border-collapse: separate;
    border-spacing: 0;
}

.pane-main .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
}

.type-card {
    margin: 0 0 10px;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
}

.type-symbol-preview {
    width: 84px;
    height: 64px;
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

.type-symbol-preview svg {
    display: block;
    width: 100%;
    height: 100%;
}

#typeSymbolHover {
    display: none;
    position: fixed;
    z-index: 1080;
    pointer-events: none;
    padding: 8px 8px 4px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#typeSymbolHover .type-symbol-frame svg {
    display: block;
    width: 140px;
    height: 108px;
}

#typeSymbolHover span {
    display: block;
    margin-top: 2px;
    color: #6c757d;
    font-size: 12px;
    text-align: center;
}

.storage-history {
    margin: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
}

.storage-main .table {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.storage-main .table th,
.storage-main .table td {
    padding: 0.5rem;
    vertical-align: middle;
}

.storage-main .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #343a40;
    color: #fff;
    white-space: nowrap;
}

.pane-main > .card-body {
    padding: 0;
}

#accBody {
    padding: 1rem;
}

.acc-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8f9fa;
    box-shadow: inset 0 -1px 0 #dee2e6;
}

@media (max-width: 992px) {
    .acc-table thead th {
        top: 60px;
    }
}

.storage-main th[data-sort]:hover {
    background-color: #2b3035;
}

.storage-main th[data-sort].sort-asc::after {
    border-bottom-color: #fff;
}

.storage-main th[data-sort].sort-desc::after {
    border-top-color: #fff;
}

.storage-component-row {
    cursor: pointer;
}

.storage-component-row .storage-row-actions,
.storage-component-row .storage-row-actions * {
    cursor: default;
}

.storage-main .card-header .form-control {
    background: #fff;
}

#componentHoverPreview {
    display: none;
    position: fixed;
    z-index: 1080;
    pointer-events: none;
    max-width: 220px;
    padding: 4px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#componentHoverPreview img {
    display: block;
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
}

.owner-filter {
    position: relative;
    flex: 0 0 auto;
}

.owner-filter-toggle {
    max-width: 220px;
}

.owner-filter-label {
    display: inline-block;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.owner-filter-chevron {
    display: inline-block;
    transition: transform 0.18s ease;
}

.owner-filter.is-open .owner-filter-chevron {
    transform: rotate(180deg);
}

.owner-filter-panel {
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    min-width: 260px;
    max-height: 320px;
    overflow: auto;
    padding: 0.35rem;
    background: #fff;
    color: #212529;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: transform 0.18s ease, opacity 0.18s ease, visibility 0.18s ease;
}

.owner-filter-panel.is-open {
    transform: none;
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.owner-filter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.4rem 0.65rem;
    border-radius: 0.375rem;
    color: #212529;
    text-decoration: none;
    white-space: nowrap;
}

.owner-filter-item:hover {
    background: #f1f3f5;
    color: inherit;
}

.owner-filter-item.is-active {
    background: #e7f1ff;
    color: #0d6efd;
    font-weight: 600;
}

th[data-sort] {
    position: relative;
    cursor: pointer;
}

th[data-sort]:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

th[data-sort].sort-asc::after,
th[data-sort].sort-desc::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}

th[data-sort].sort-asc::after {
    border-bottom: 5px solid #333;
    transform: translateY(-70%);
}

th[data-sort].sort-desc::after {
    border-top: 5px solid #333;
    transform: translateY(-30%);
}
