/* Hotel Procurement — minimal app-specific overrides on top of Bootstrap 5 */

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ─── App shell: fixed left sidebar + main column ───────────────── */
body.app-page {
    margin: 0;
    min-height: 100vh;
    background-color: #f8f9fa;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    width: 260px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    color: #4b5563;
    border-right: 1px solid #e5e7eb;
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
    transition: width 0.22s ease;
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.65rem 0.5rem 0.65rem 0.6rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: 1rem;
    min-height: 3.25rem;
}

.app-sidebar-rail-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 0.35rem;
    background: #f3f4f6;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.app-sidebar-rail-toggle:hover {
    background: #e5e7eb;
    color: #111827;
}

.app-sidebar-rail-toggle-icon {
    display: block;
    transition: transform 0.2s ease;
}

body.app-sidebar-collapsed .app-sidebar-rail-toggle-icon {
    transform: scaleX(-1);
}

.app-sidebar-brand-link {
    min-width: 0;
    flex: 1;
    color: #2563eb;
    text-align: center;
    /* offset the toggle button's width so PRISMA sits centered across the sidebar */
    margin-right: 2.6rem;
}

.app-sidebar-brand-link:hover {
    color: #1d4ed8;
}

.app-sidebar-brand-short {
    display: none;
}

.app-sidebar-icon {
    flex-shrink: 0;
    opacity: 0.92;
}

.app-sidebar-nav {
    overflow-y: auto;
    padding: 0.75rem 0.5rem 1rem;
}

.app-sidebar-section-label {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
    padding: 0.5rem 0.75rem 0.35rem;
    font-weight: 600;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    margin-bottom: 2px;
    border-radius: 0.35rem;
    color: #4b5563;
    text-decoration: none;
    font-size: 0.925rem;
    transition: background 0.12s ease, color 0.12s ease;
}

.app-sidebar-link:hover {
    background: #f3f4f6;
    color: #111827;
}

.app-sidebar-link.active {
    background: #dbeafe;
    color: #2563eb;
    font-weight: 600;
}

.app-sidebar-link.active .app-sidebar-icon {
    opacity: 1;
}

.app-sidebar-collapse-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.45rem 0.75rem;
    margin-bottom: 2px;
    border: none;
    border-radius: 0.35rem;
    background: transparent;
    color: #4b5563;
    font-size: 0.925rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    list-style: none;
}

.app-sidebar-collapse-toggle .app-sidebar-label {
    flex: 1;
    min-width: 0;
}

.app-sidebar-collapse-toggle .app-sidebar-chevron {
    margin-left: 0;
}

.app-sidebar-collapse-toggle::-webkit-details-marker {
    display: none;
}

.app-sidebar-collapse-toggle:hover {
    background: #f3f4f6;
    color: #111827;
}

.app-sidebar-chevron {
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    margin-left: 0.5rem;
    border-right: 2px solid #9ca3af;
    border-bottom: 2px solid #9ca3af;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.app-sidebar-admin[open] .app-sidebar-chevron {
    transform: rotate(-135deg);
}

.app-sidebar-submenu {
    padding: 0.15rem 0 0.35rem 0.35rem;
}

.app-sidebar-sublink {
    display: block;
    padding: 0.35rem 0.65rem 0.35rem 1.25rem;
    margin-bottom: 1px;
    border-radius: 0.3rem;
    font-size: 0.875rem;
    color: #6b7280;
    text-decoration: none;
    border-left: 2px solid transparent;
}

.app-sidebar-sublink:hover {
    background: #f3f4f6;
    color: #111827;
}

.app-sidebar-sublink.active {
    color: #2563eb;
    background: #dbeafe;
    border-left-color: #2563eb;
    font-weight: 600;
}

/* Icon-only admin links — visible only in collapsed rail */
.app-sidebar-admin-rail {
    display: none;
    flex-direction: column;
    gap: 2px;
}

.app-sidebar-link--rail .app-sidebar-label {
    display: none;
}

.app-sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

/* ─── Signed-in user frame ─────────────────────────────────────── */
.app-sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
    padding: 0.6rem 0.7rem;
    border-radius: 0.7rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
    color: #fff;
}

.app-sidebar-user-avatar {
    flex: 0 0 auto;
    width: 2.1rem;
    height: 2.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.app-sidebar-user-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.app-sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.15;
    color: #fff;
}

.app-sidebar-user-role {
    align-self: flex-start;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: #6d28d9;
}

.app-sidebar-signout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
}

.app-sidebar-signout-icon {
    display: none;
}

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.22s ease;
}

.app-footer {
    margin-top: auto;
}

@media (max-width: 767.98px) {
    .app-sidebar {
        width: 220px;
    }
    .app-main {
        margin-left: 220px;
    }
}

/* ─── Collapsed (condensed) rail ───────────────────────────────── */
body.app-sidebar-collapsed .app-sidebar {
    width: 4.25rem;
}

body.app-sidebar-collapsed .app-main {
    margin-left: 4.25rem;
}

body.app-sidebar-collapsed .app-sidebar-brand-full,
body.app-sidebar-collapsed .app-sidebar-brand-short {
    display: none;
}

body.app-sidebar-collapsed .app-sidebar-brand-link {
    display: none;
}

/* Collapsed rail: section labels can't show their text, so render each as a thin
   horizontal separator instead — keeps the section boundaries visually clear. */
body.app-sidebar-collapsed .app-sidebar-section-label {
    position: static;
    width: auto;
    height: 0;
    padding: 0;
    margin: 0.5rem 0.4rem;
    overflow: hidden;
    clip: auto;
    white-space: nowrap;
    border: 0;
    border-top: 1px solid #e5e7eb;
    font-size: 0;
    line-height: 0;
    color: transparent;
    /* beat Bootstrap's .mt-3 !important on the "Procurement Plan" label so every
       section separator gets the same spacing */
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
}

/* No separator above the first section — it sits directly under the brand divider. */
body.app-sidebar-collapsed .app-sidebar-nav > .app-sidebar-section-label:first-child {
    border-top: 0;
    margin: 0 !important;
}

body.app-sidebar-collapsed .app-sidebar-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Keep admin rail link labels hidden (already icon-only); clip rule above applies to main links */
body.app-sidebar-collapsed .app-sidebar-link {
    justify-content: center;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

body.app-sidebar-collapsed .app-sidebar-admin-expanded {
    display: none !important;
}

body.app-sidebar-collapsed .app-sidebar-admin-rail {
    display: flex;
}

body.app-sidebar-collapsed .app-sidebar-user-text {
    display: none;
}

body.app-sidebar-collapsed .app-sidebar-user {
    justify-content: center;
    gap: 0;
    padding: 0.4rem;
    margin-bottom: 0.55rem;
}

body.app-sidebar-collapsed .app-sidebar-footer {
    padding: 0.65rem 0.4rem;
}

body.app-sidebar-collapsed .app-sidebar-signout-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.app-sidebar-collapsed .app-sidebar-signout-icon {
    display: block;
}

body.app-sidebar-collapsed .app-sidebar-signout {
    width: auto;
    min-width: 2.25rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
}

body.app-sidebar-collapsed .app-sidebar-footer form {
    margin-bottom: 0;
}

@media (max-width: 767.98px) {
    body.app-sidebar-collapsed .app-sidebar {
        width: 4.25rem;
    }
    body.app-sidebar-collapsed .app-main {
        margin-left: 4.25rem;
    }
}

/* Item form section dividers ("General information" / "Original version"). */
.item-form-section-header {
    border-top: 1px solid #dee2e6;
    padding-top: 0.75rem;
    cursor: pointer;
    user-select: none;
}
.item-form-section-header:first-of-type {
    border-top: 0;
    padding-top: 0;
}
.item-form-section-header h5 {
    letter-spacing: 0.02em;
}
.item-form-section-header:hover h5 {
    text-decoration: underline;
    text-decoration-color: rgba(13, 110, 253, 0.4);
    text-underline-offset: 3px;
}
.item-form-section-chevron {
    display: inline-block;
    transition: transform 0.18s ease;
    margin-right: 0.4rem;
    color: #6c757d;
    font-size: 0.85em;
}
.item-form-section-header[aria-expanded="false"] .item-form-section-chevron {
    transform: rotate(-90deg);
}
.item-form-section-content.item-form-collapsed {
    display: none;
}

/* Per-card collapse inside a section. */
.item-form-section-content .card > .card-header {
    user-select: none;
}
.item-form-section-content .card > .card-header:hover {
    background-color: rgba(0, 0, 0, 0.03);
}
.item-form-card-chevron {
    display: inline-block;
    margin-right: 0.4rem;
    color: #6c757d;
    font-size: 0.85em;
    transition: transform 0.18s ease;
}
.item-form-section-content .card.item-form-card-collapsed > .card-header .item-form-card-chevron {
    transform: rotate(-90deg);
}
.item-form-section-content .card.item-form-card-collapsed > .card-body {
    display: none;
}

/* Card hover lift for tiles on the dashboard */
.card {
    transition: box-shadow .15s ease-in-out;
}
.card:hover {
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .08);
}

/* Tighter display numerals on dashboard tiles */
.display-6 {
    font-weight: 600;
    line-height: 1.1;
}

/* ─── Dashboard KPI cards ─────────────────────────────────────── */
.kpi-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem 1.1rem;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-left: 4px solid #adb5bd;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    color: #212529;
    transition: transform .12s ease, box-shadow .15s ease;
    height: 100%;
}
a.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 .35rem 1rem rgba(0, 0, 0, .08);
    color: #212529;
}
.kpi-card .kpi-icon {
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    border-radius: 0.5rem;
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
}
.kpi-card .kpi-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    font-weight: 600;
}
.kpi-card .kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.1;
    color: #212529;
}
.kpi-primary  { border-left-color: #0d6efd; }
.kpi-primary  .kpi-icon { background: rgba(13, 110, 253, 0.12);  color: #0d6efd; }
.kpi-success  { border-left-color: #198754; }
.kpi-success  .kpi-icon { background: rgba(25, 135, 84, 0.12);   color: #198754; }
.kpi-warning  { border-left-color: #fd7e14; }
.kpi-warning  .kpi-icon { background: rgba(253, 126, 20, 0.14);  color: #fd7e14; }
.kpi-danger   { border-left-color: #dc3545; }
.kpi-danger   .kpi-icon { background: rgba(220, 53, 69, 0.12);   color: #dc3545; }
.kpi-info     { border-left-color: #0dcaf0; }
.kpi-info     .kpi-icon { background: rgba(13, 202, 240, 0.14);  color: #0aa2c0; }

/* Subtle row-hover for item tables (Phase 1b) */
.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* HTMX indicator — show a little spinner while a request is in flight */
.htmx-indicator {
    display: none;
    opacity: 0;
    transition: opacity .2s ease;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
    opacity: 1;
}

/* Stale data flag for FX rates etc. */
.stale-flag {
    color: #b45309;
    font-size: .8rem;
    font-weight: 500;
}

/* Item list: first thumbnail + count badge for remaining images */
.item-list-images-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    min-width: 0;
}

.item-list-images-more-below {
    display: flex;
    align-items: center;
}

.item-thumb-primary {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    flex-shrink: 0;
    cursor: zoom-in;
}

.item-gallery-more {
    padding: 2px 6px !important;
    font-size: 0.7rem;
    line-height: 1.1;
    display: inline-flex !important;
    align-items: center;
    gap: 3px;
    cursor: pointer;
}

.item-gallery-more-icon {
    display: flex;
    opacity: 0.85;
}

.item-gallery-more-count {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Items list: enlarged image modal + gallery nav */
.item-list-image-modal-body {
    min-height: 120px;
}

.item-list-image-modal-img {
    max-width: 100%;
    max-height: min(85vh, 920px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.item-list-image-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    padding: 0.2rem 0.45rem;
    line-height: 1;
    font-size: 1.35rem;
    font-weight: 600;
}

.item-list-image-modal-prev {
    left: 0.35rem;
}

.item-list-image-modal-next {
    right: 0.35rem;
}

.item-list-image-modal-nav:disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* Item image thumbnails (detail page) */

.item-detail-thumb {
    max-height: 160px;
    max-width: 220px;
    object-fit: contain;
    display: block;
}

/* ─── Items list: horizontal scroll + optional frozen columns ───────── */
#item-list-col-visibility-toggle[aria-expanded="true"] .item-list-col-visibility-chevron {
    transform: rotate(90deg);
}

.item-list-col-visibility-chevron {
    display: inline-block;
    transition: transform 0.15s ease;
    font-size: 0.65rem;
    line-height: 1;
    width: 0.75rem;
    text-align: center;
}

/* Grouped "Choose visible columns" layout: title stacked above its checkboxes,
   everything left-aligned. The title sits as a small heading on its own line so
   the checkbox grid below can flow naturally from the left edge of the card. */
#item-list-col-checkboxes {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}
.item-list-col-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    width: 100%;
}
.item-list-col-group-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    color: #495057;
    text-align: left;
    padding: 0 0 0.15rem 0;
    border-bottom: 1px solid #dee2e6;
    width: 100%;
}
.item-list-col-group-items {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.15rem 0.75rem;
    align-items: baseline;
    width: 100%;
}

.item-list-table th.item-list-col-hidden,
.item-list-table td.item-list-col-hidden {
    display: none !important;
}

.item-list-scroll-wrap {
    /* Scroll the table body inside this box (both axes) so the header row can stay
       frozen via position:sticky. Height is capped to the viewport minus the page
       chrome above (heading + toolbar + filter bar) and the pagination below.
       On the items page the .item-list-shell rules below override this to fill all
       remaining vertical space dynamically. */
    overflow: auto;
    max-height: calc(100vh - 13rem);
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Items list: pin the page to the viewport and let the table consume every bit of
   leftover vertical space (then scroll internally) instead of leaving a gap below
   and scrolling the whole window. */
.item-list-shell {
    height: 100vh;
    overflow: hidden;
}
.item-list-shell > main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.item-list-shell > main > .card {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.item-list-shell .item-list-scroll-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}
/* The expandable column-chooser must scroll within itself, not push the (now
   height-bounded) card and get clipped. */
.item-list-shell #item-list-col-visibility {
    max-height: 45vh;
    overflow: auto;
}

.item-list-table {
    font-size: 0.8125rem;
}

/* Minimum width for every column (floor; matches the JS resize clamp). Declared early so the
   wider per-column minimums defined later win on equal specificity. */
.item-list-table th[data-col-id],
.item-list-table td[data-col-id] {
    min-width: 2.5rem;
}

/* Thin vertical + horizontal separators between cells. Drawn with inset box-shadow
   so frozen (position:sticky) cells render the dividers at their own stacking layer —
   otherwise non-frozen cells scrolling underneath can paint text through the 1px
   border area. Bootstrap's default border-bottom on cells is suppressed and replaced
   by the bottom inset-shadow below; both right + bottom dividers come from this rule. */
.item-list-table th,
.item-list-table td {
    border-bottom: 0 !important;
    box-shadow: inset -1px 0 0 #dee2e6, inset 0 -1px 0 #dee2e6;
}
.item-list-table th:last-child,
.item-list-table td:last-child {
    box-shadow: inset 0 -1px 0 #dee2e6;
}

/* Column titles: match compliance block size; centered in cell */
.item-list-table thead th {
    font-size: 0.6875rem;
    line-height: 1.15;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    padding: 0.35rem 0.25rem;
}

/* Clip cell content on hover + scroll; keep scrolling columns under sticky ones */
.item-list-table tbody td:not(.item-list-frozen) {
    position: relative;
    z-index: 0;
}

/* Freeze the header row: every header cell sticks to the top of the scroll wrap.
   Opaque background so body rows scroll underneath without bleeding through. */
.item-list-table thead th:not(.item-list-frozen) {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: #fff;
}

.item-list-table thead th,
.item-list-table tbody td {
    overflow: hidden;
    vertical-align: middle;
}

/* Single-line text columns */
.item-list-table th[data-col-id="code"],
.item-list-table td[data-col-id="code"] {
    max-width: 7rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-list-table th[data-col-id="status"],
.item-list-table td[data-col-id="status"] {
    max-width: 9rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-list-table th[data-col-id="type"],
.item-list-table td[data-col-id="type"] {
    max-width: 5rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-list-table th[data-col-id="areaType"],
.item-list-table td[data-col-id="areaType"] {
    max-width: 10rem;
    white-space: normal;
    word-break: break-word;
    overflow-x: hidden;
}

.item-list-table th[data-col-id="areaName"],
.item-list-table td[data-col-id="areaName"] {
    max-width: 12rem;
    white-space: normal;
    word-break: break-word;
    overflow-x: hidden;
}

.item-list-table th[data-col-id="initiator"],
.item-list-table td[data-col-id="initiator"] {
    max-width: 11rem;
    white-space: normal;
    word-break: break-word;
    overflow-x: hidden;
}

/* Narrow Edit/actions column — just the icon, no padding around it. */
.item-list-table th[data-col-id="actions"],
.item-list-table td[data-col-id="actions"] {
    width: 2.25rem;
    max-width: 2.25rem;
    min-width: 2.25rem;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
}
.item-list-table td[data-col-id="actions"] .btn {
    padding: 0.15rem 0.25rem;
    line-height: 1;
}
.item-list-table td[data-col-id="actions"] .btn svg {
    width: 12px;
    height: 12px;
}

/* ─── Alternatives (bidding versions) ─────────────────────────── */
.item-alt-toggle {
    display: none;            /* shown only when body.item-list-show-alts is set */
    width: 1rem;
    height: 1rem;
    padding: 0;
    margin-right: 0.25rem;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    vertical-align: middle;
    border-radius: 0.25rem;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.item-alt-toggle:hover,
.item-alt-toggle:focus-visible {
    background-color: rgba(0, 0, 0, 0.06);
    color: #212529;
    outline: none;
}
.item-alt-toggle svg {
    transition: transform 0.15s ease;
}
.item-alt-toggle[aria-expanded="true"] svg {
    transform: rotate(-180deg);
}
body.item-list-show-alts .item-list-main-row[data-has-alts="true"] .item-alt-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
body:not(.item-list-show-alts) .item-alt-count {
    display: none;
}
/* Item version cell: stack label → count → chevron vertically to save width. */
.item-version-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.item-version-stack .item-alt-count {
    margin-left: 0;
}
.item-version-stack .badge {
    white-space: normal;
    word-break: break-word;
    font-size: 0.7rem;      /* match the sub-row "Original" label (td.small) */
    font-weight: 600;
    padding: 0.12em 0.4em;
}
.item-list-table th[data-col-id="itemVersion"],
.item-list-table td[data-col-id="itemVersion"] {
    width: 4.5rem;
    min-width: 4.5rem;
    max-width: 4.5rem;
}
.item-list-alt-row > td {
    background: #f8fafc;
    /* All four dividers via inset shadow (mirrors the main-row technique): top +
       bottom horizontal + right vertical. Inset shadows are part of the cell's own
       painting at its z-index, so frozen cells render them on top of any non-frozen
       content scrolling underneath. */
    box-shadow: inset 0 1px 0 #dee2e6, inset -1px 0 0 #dee2e6, inset 0 -1px 0 #dee2e6;
    font-size: 0.78125rem;
}
.item-list-alt-row > td:last-child {
    box-shadow: inset 0 1px 0 #dee2e6, inset 0 -1px 0 #dee2e6;
}
/* The frozen-edge cell keeps its slightly darker border-right; here we re-add the
   top + bottom dividers so horizontal lines stay continuous across the boundary. */
.item-list-alt-row > td.item-list-frozen-edge {
    box-shadow: inset 0 1px 0 #dee2e6, inset 0 -1px 0 #dee2e6;
}
.item-list-alt-row.is-selected > td {
    background: #eff6ff;
}

/* Cells in the main row that span across alt sub-rows (rowspan applied by JS
   only when the item is expanded). Center horizontally + vertically — wins over
   per-column text alignment so shared cells visibly merge as one centered block. */
.item-list-table td.item-list-merged-cell {
    text-align: center !important;
    vertical-align: middle !important;
}

/* Per-cell hide used on alt rows for columns merged into the main row.
   Different from row-level d-none: only individual cells disappear, letting
   the remaining alt-row cells still occupy the unmerged columns. */
.item-list-table td.item-list-alt-cell-hidden {
    display: none !important;
}

/* Compact, centered date/period columns — headers wrap to 2 lines */
.item-list-table th[data-col-id="productionPeriod"],
.item-list-table td[data-col-id="productionPeriod"],
.item-list-table th[data-col-id="productionPeriodUnit"],
.item-list-table td[data-col-id="productionPeriodUnit"],
.item-list-table th[data-col-id="itemInitiationDate"],
.item-list-table td[data-col-id="itemInitiationDate"],
.item-list-table th[data-col-id="transportationPeriod"],
.item-list-table td[data-col-id="transportationPeriod"],
.item-list-table th[data-col-id="transportationPeriodUnit"],
.item-list-table td[data-col-id="transportationPeriodUnit"],
.item-list-table th[data-col-id="firstAdvancePaymentDate"],
.item-list-table td[data-col-id="firstAdvancePaymentDate"],
.item-list-table th[data-col-id="transportationStartDate"],
.item-list-table td[data-col-id="transportationStartDate"] {
    max-width: 5.5rem;
    width: 5.5rem;
    white-space: normal;
    word-break: break-word;
    text-align: center;
    overflow-x: hidden;
}

/* Compact codes: long-ish alphanumeric strings that don't need full column width.
   Header wraps to 2 lines ("Customs Declaration / Code"). Cell content wraps on
   any character so a 30-char code doesn't blow the column open. */
.item-list-table th[data-col-id="customsDeclarationCode"],
.item-list-table td[data-col-id="customsDeclarationCode"],
.item-list-table th[data-col-id="rsInvoiceCode"],
.item-list-table td[data-col-id="rsInvoiceCode"] {
    max-width: 7rem;
    width: 7rem;
    white-space: normal;
    word-break: break-word;
    text-align: center;
    overflow-x: hidden;
}

.item-list-table th[data-col-id="opsLead"],
.item-list-table td[data-col-id="opsLead"] {
    max-width: 12rem;
    white-space: normal;
    word-break: break-word;
    overflow-x: hidden;
}

.item-list-table th[data-col-id="procurementManager"],
.item-list-table td[data-col-id="procurementManager"],
.item-list-table th[data-col-id="projectManager"],
.item-list-table td[data-col-id="projectManager"] {
    max-width: 11rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Compliance & approvals (list) */
.item-list-table th.compliance-block-start,
.item-list-table td.compliance-block-start {
    border-left: 1px solid var(--bs-border-color);
    padding-left: 0.4rem;
}

/* Compliance titles: allow wrap; size/weight/center come from thead th above */
.item-list-table thead th.compliance-col-head {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 4.5rem;
    min-width: 3.25rem;
}

.item-list-table td[data-col-id^="compliance-"] {
    max-width: 5rem;
    white-space: normal;
    word-break: break-word;
    overflow-x: hidden;
}

.item-list-table td.compliance-list-cell .badge {
    font-size: 0.65rem;
    font-weight: 500;
}

/* No compliance row yet */
.item-list-table td.compliance-list-cell .compliance-empty-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    padding: 0.15rem 0.25rem;
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
    opacity: 0.75;
}

/* Not required — calm pill, reads as “cleared / no action” */
.item-list-table td.compliance-list-cell .compliance-not-required-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    max-width: 100%;
    padding: 0.18rem 0.38rem 0.18rem 0.32rem;
    font-size: 0.58rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: 0.02em;
    color: var(--bs-secondary-color);
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--bs-success-bg-subtle, #d1e7dd) 55%, var(--bs-body-bg, #fff) 45%) 0%,
        color-mix(in srgb, var(--bs-success-bg-subtle, #d1e7dd) 35%, var(--bs-body-bg, #fff) 65%) 100%
    );
    border: 1px solid color-mix(in srgb, var(--bs-success, #198754) 22%, var(--bs-border-color) 78%);
    border-radius: 0.35rem;
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--bs-body-bg, #fff) 65%, transparent);
}

.item-list-table td.compliance-list-cell .compliance-not-required-dot {
    flex-shrink: 0;
    width: 0.35rem;
    height: 0.35rem;
    border-radius: 50%;
    background-color: color-mix(in srgb, var(--bs-success, #198754) 55%, var(--bs-secondary-color) 45%);
    opacity: 0.85;
}

.item-list-table td.compliance-list-cell .compliance-not-required-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@supports not (background: color-mix(in srgb, white, black)) {
    .item-list-table td.compliance-list-cell .compliance-not-required-chip {
        background: var(--bs-success-bg-subtle, #d1e7dd);
        border-color: var(--bs-border-color);
    }

    .item-list-table td.compliance-list-cell .compliance-not-required-dot {
        background-color: var(--bs-success, #198754);
        opacity: 0.5;
    }
}

.item-list-table th[data-col-id="description"],
.item-list-table td[data-col-id="description"] {
    max-width: 18rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-list-table th[data-col-id="usdTotal"],
.item-list-table td[data-col-id="usdTotal"] {
    max-width: 8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-list-table th[data-col-id="urgency"],
.item-list-table td[data-col-id="urgency"] {
    max-width: 8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-list-table th[data-col-id="updated"],
.item-list-table td[data-col-id="updated"] {
    max-width: 10rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Thumbnail column */
.item-list-table th[data-col-id="images"],
.item-list-table td[data-col-id="images"] {
    max-width: 12.5rem;
    white-space: normal;
}

.item-list-table td[data-col-id="images"] .item-list-images-stack {
    min-width: 0;
}

/* Multi-line price / qty blocks */
.item-list-table th[data-col-id="qty"],
.item-list-table td[data-col-id="qty"],
.item-list-table th[data-col-id="costPerUnit"],
.item-list-table td[data-col-id="costPerUnit"] {
    max-width: 17rem;
    white-space: normal;
    word-break: break-word;
    overflow-x: hidden;
}

.item-list-table thead th.item-list-th-draggable {
    cursor: grab;
    user-select: none;
}

.item-list-table thead th.item-list-th-draggable:active {
    cursor: grabbing;
}

.item-list-table thead th.item-list-drag-over {
    outline: 2px dashed var(--bs-primary);
    outline-offset: -2px;
}

.item-list-table thead th.item-list-frozen,
.item-list-table tbody td.item-list-frozen {
    position: sticky;
    /* Extend the opaque background through the 1px border-right area so the
       per-column divider stays solid when non-frozen cells scroll underneath. */
    background-clip: border-box;
    overflow: hidden;
}

.item-list-table thead th.item-list-frozen {
    /* Frozen + header → sticky on both axes; sits above the sticky header row
       and the frozen body column at the top-left corner. */
    top: 0;
    background-color: var(--bs-secondary-bg, #e9ecef);
    z-index: 30;
}

.item-list-table tbody td.item-list-frozen {
    background-color: var(--bs-body-bg, #fff);
    z-index: 15;
}

/*
 * Frozen body cells must use an opaque hover fill. A translucent rgba (e.g. the old 0.02 alpha)
 * lets horizontally scrolled cells paint through the sticky stack when the row is hovered.
 */
.item-list-table tbody tr:hover td.item-list-frozen {
    background-color: var(--bs-secondary-bg, #e9ecef);
    background-color: color-mix(in srgb, var(--bs-body-bg, #fff) 92.5%, var(--bs-emphasis-color, #212529) 7.5%);
}

/* ─── Inline cell editor: pencil-on-hover + locked-row indicator ─────────
   • Editable cells gain a subtle outline + pencil button in their top-right
     corner. The pencil is invisible until the cell is hovered.
   • Rows currently locked by another user are dimmed; their pencils are
     suppressed; a small 🔒 badge appears next to the row's edit cell. */
.item-list-table td.item-list-editable-cell {
    position: relative;
}
.item-list-edit-pencil {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 1.1rem;
    height: 1.1rem;
    padding: 0;
    border: 0;
    border-radius: 0.2rem;
    background: rgba(255, 255, 255, 0.92);
    color: var(--bs-secondary-color, #6c757d);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    opacity: 0;
    transition: opacity 0.12s, background-color 0.12s, color 0.12s;
    cursor: pointer;
    z-index: 4;
}
.item-list-table tr:hover td.item-list-editable-cell .item-list-edit-pencil,
.item-list-table td.item-list-editable-cell:hover .item-list-edit-pencil,
.item-list-table td.item-list-editable-cell:focus-within .item-list-edit-pencil {
    opacity: 0.9;
}
.item-list-edit-pencil:hover,
.item-list-edit-pencil:focus-visible {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    opacity: 1;
    outline: none;
}
/* Frozen cells have higher z-index than scrolling cells; bump the pencil so it
   doesn't get hidden when the user scrolls the table horizontally. */
.item-list-table td.item-list-frozen.item-list-editable-cell .item-list-edit-pencil {
    z-index: 26;
}

/* Locked-by-other row state: dim the row, suppress its pencils, and inject a
   small lock indicator in the actions cell via ::before on a known anchor. */
.item-list-table tr.item-list-row-locked-by-other {
    background-color: rgba(255, 193, 7, 0.06);
}
.item-list-table tr.item-list-row-locked-by-other td.item-list-editable-cell {
    cursor: not-allowed;
}
.item-list-table tr.item-list-row-locked-by-other td.item-list-editable-cell .item-list-edit-pencil {
    display: none;
}
.item-list-table tr.item-list-row-locked-by-other td[data-col-id="actions"]::before {
    content: '🔒';
    font-size: 0.85rem;
    margin-right: 0.25rem;
    vertical-align: middle;
    color: var(--bs-warning-emphasis, #b88600);
}

/* Inline editor modal body — give the checkbox lists a sensible max height
   so a long multi-enum (pendingReasons: 14 items, opsLeads: N users) doesn't
   blow up the modal. */
.inline-cell-editor .inline-cell-checks {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem;
    padding: 0.5rem 0.75rem;
}

/* Mirror BACKGROUND layer that paints chip-shaped tints behind each @mention.
   The mirror text itself is fully transparent; only .mention-tag spans carry
   a visible background. The textarea above keeps its normal text colour —
   what the user sees is "real text + a coloured highlight under each mention".
   See comment-mention.js → ensureMirror() for the geometry sync. */
.mention-mirror {
    color: transparent !important;
    pointer-events: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    /* Layered behind the textarea — see textarea z-index in ensureMirror. */
    z-index: 0;
}
.mention-mirror .mention-tag {
    background: var(--bs-primary-bg-subtle, #cfe2ff);
    color: transparent !important; /* hide mirror text — textarea paints the real chars */
    border-radius: 0.25rem;
    /* Small inset on the chip background; padding here would shift glyph
       positions and misalign with the textarea, so use box-shadow as the
       visual "padding" instead. */
    box-shadow: 0 0 0 1px var(--bs-primary-border-subtle, #9ec5fe) inset;
}

/* @mention autosuggest popup attached to comment textareas.
   Absolute-positioned (placed by JS), sits above other content. Keyboard-navigable;
   currently-highlighted row has .is-selected. */
.mention-suggest-popup {
    position: absolute;
    z-index: 2050;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.35rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    max-height: 240px;
    overflow-y: auto;
}
.mention-suggest-row {
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    white-space: nowrap;
}
.mention-suggest-row:hover,
.mention-suggest-row.is-selected {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
}
.mention-suggest-username {
    font-weight: 600;
}
.mention-suggest-fullname {
    font-size: 0.78rem;
    opacity: 0.75;
}
.mention-suggest-empty {
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
    font-style: italic;
}

/* Image manager (IMAGES editor) — grid of square thumbs with a small remove
   checkbox sitting in the corner. */
.inline-cell-images .inline-cell-image-tile {
    position: relative;
    width: 90px;
    height: 90px;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.35rem;
    overflow: hidden;
    background: var(--bs-secondary-bg, #f1f3f5);
}
.inline-cell-images .inline-cell-image-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.inline-cell-images .inline-cell-image-remove {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.inline-cell-images .inline-cell-image-remove input[type="checkbox"] {
    margin: 0;
    accent-color: var(--bs-danger, #dc3545);
}

/* Modal-mode wrapper for alternative-form.html when loaded inside the items-list
   "Add alternative" iframe popup. We keep the same template but drop chrome:
   no sidebar, no app-shell vertical layout constraints, no footer. The iframe
   provides its own scroll context, so the body just needs to flow normally. */
.item-alt-modal-mode {
    background: var(--bs-body-bg, #fff);
}
.item-alt-modal-mode .app-shell {
    display: block;
    min-height: 0;
}
.item-alt-modal-mode .app-shell > .app-main {
    width: 100%;
    margin: 0;
    padding: 0;
}
.item-alt-modal-mode main {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

/* Pending-reasons column: narrow, vertically/horizontally centered, one chip per line.
   Bootstrap's badge utilities default to inline-block side-by-side flow — we override to
   stack each chip as its own block, centered with auto margins. */
.item-list-table th[data-col-id="pendingReasons"],
.item-list-table td[data-col-id="pendingReasons"] {
    max-width: 7.5rem;
    min-width: 5.5rem;
    text-align: center;
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
}
.item-list-table td[data-col-id="pendingReasons"] .badge {
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto 0.2rem auto;
    white-space: normal;
    word-break: break-word;
    line-height: 1.15;
}
.item-list-table td[data-col-id="pendingReasons"] .badge:last-child {
    margin-bottom: 0;
}

/* Border instead of box-shadow so it survives overflow clipping on sticky cells.
   Keep the bottom inset-shadow divider so this edge cell still has its row separator,
   but use the explicit border-right (slightly darker) as the frozen→scroll divider. */
.item-list-table thead th.item-list-frozen-edge,
.item-list-table tbody td.item-list-frozen-edge {
    border-right: 1px solid rgba(0, 0, 0, 0.14);
    box-shadow: inset 0 -1px 0 #dee2e6;
}

/* Per-column filter icon (rendered inside the <th> by item-list-table.js). */
.item-list-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    margin-left: 0.25rem;
    padding: 0;
    border: 0;
    border-radius: 0.25rem;
    background: transparent;
    color: var(--bs-secondary-color, #6c757d);
    vertical-align: middle;
    line-height: 0;
    cursor: pointer;
    opacity: 0.75;
    transition: background-color 0.12s, color 0.12s, opacity 0.12s;
}
.item-list-filter-btn:hover,
.item-list-filter-btn:focus-visible {
    background: rgba(0, 0, 0, 0.08);
    color: var(--bs-body-color, #212529);
    opacity: 1;
    outline: none;
}
.item-list-filter-btn--active {
    color: var(--bs-primary, #0d6efd);
    background: rgba(13, 110, 253, 0.14);
    opacity: 1;
}
.item-list-filter-btn--active:hover,
.item-list-filter-btn--active:focus-visible {
    background: rgba(13, 110, 253, 0.22);
    color: var(--bs-primary, #0d6efd);
}

/* Filterable column header: title on the left, filter icon pinned to the right
   (so the funnel never wraps below the title). The flex layout lives on an inner
   wrapper — NOT the <th> itself, since display:flex on a table cell breaks the
   table's column sizing. */
.item-list-th-inner {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    width: 100%;
}
.item-list-th-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;     /* never let the title spill under the sort/filter icons */
    text-align: center;   /* heading text horizontally centered */
}
.item-list-th-inner .item-list-filter-btn {
    flex: 0 0 auto;       /* funnel pinned to the right */
}

/* Clickable column-header sorting. */
.item-list-sort-title {
    cursor: pointer;
    user-select: none;
}
.item-list-sort-title:hover {
    text-decoration: underline;
}
.item-list-sort-arrow {
    flex: 0 0 auto;       /* its own column, separated from the funnel by the inner's gap */
    color: var(--bs-primary, #0d6efd);
    font-size: 0.85em;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
}

/* Per-column header widths so the title + filter icon read cleanly.
   min-width beats the .compliance-col-head max-width cap and won't clip body cells. */
/* One line: keep title + funnel on a single line. */
.item-list-table th[data-col-id="compliance-COMPLIANCE_COPYRIGHT"],
.item-list-table td[data-col-id="compliance-COMPLIANCE_COPYRIGHT"],
.item-list-table th[data-col-id="reqPrototype"],
.item-list-table td[data-col-id="reqPrototype"] { min-width: 5.75rem; }
.item-list-table th[data-col-id="reqStrikeOff"],
.item-list-table td[data-col-id="reqStrikeOff"] { min-width: 6rem; }
.item-list-table thead th[data-col-id="compliance-COMPLIANCE_COPYRIGHT"] .item-list-th-title,
.item-list-table thead th[data-col-id="reqPrototype"] .item-list-th-title,
.item-list-table thead th[data-col-id="reqStrikeOff"] .item-list-th-title { white-space: nowrap; }
/* Two lines: widen so the heading wraps to two lines (and no more). */
.item-list-table th[data-col-id="reqSeamingDiagram"],
.item-list-table td[data-col-id="reqSeamingDiagram"] { min-width: 6rem; }
.item-list-table th[data-col-id="reqFlameCertificate"],
.item-list-table td[data-col-id="reqFlameCertificate"],
.item-list-table th[data-col-id="compliance-LIGHTING_CONSULTANT_APPROVAL"],
.item-list-table td[data-col-id="compliance-LIGHTING_CONSULTANT_APPROVAL"],
.item-list-table th[data-col-id="itemInitiationDate"],
.item-list-table td[data-col-id="itemInitiationDate"] { min-width: 6.5rem; }
.item-list-table th[data-col-id="firstAdvancePaymentDate"],
.item-list-table td[data-col-id="firstAdvancePaymentDate"] { min-width: 7rem; }
.item-list-table th[data-col-id="transportationPeriodUnit"],
.item-list-table td[data-col-id="transportationPeriodUnit"],
.item-list-table th[data-col-id="transportationStartDate"],
.item-list-table td[data-col-id="transportationStartDate"] { min-width: 7.5rem; }
.item-list-table th[data-col-id="customsDeclarationCode"],
.item-list-table td[data-col-id="customsDeclarationCode"] { min-width: 8rem; }
.item-list-table th[data-col-id="materialPaymentTerms"],
.item-list-table td[data-col-id="materialPaymentTerms"],
.item-list-table th[data-col-id="laborPaymentTerms"],
.item-list-table td[data-col-id="laborPaymentTerms"],
.item-list-table th[data-col-id="transportationPaymentTerms"],
.item-list-table td[data-col-id="transportationPaymentTerms"] { min-width: 6.5rem; }

/* Description: wrap the full text across multiple lines within a bounded width. */
.item-list-table td[data-col-id="description"] {
    white-space: normal;
    word-break: break-word;
    vertical-align: middle;
}
.item-list-table th[data-col-id="description"],
.item-list-table td[data-col-id="description"] {
    min-width: 12rem;
    max-width: 22rem;
}

/* Manual column resize: a drag handle on the right edge of each header cell. */
.item-list-col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 6;
    user-select: none;
}
.item-list-col-resizer:hover,
body.item-list-col-resizing .item-list-col-resizer {
    background: rgba(13, 110, 253, 0.35);
}
body.item-list-col-resizing {
    cursor: col-resize !important;
    user-select: none !important;
}

/* Popover container that holds the per-column filter widget. Bootstrap injects
   our content under .popover-body — sized comfortably for the multi-select lists. */
.item-list-filter-popover-tip {
    max-width: 280px;
}
.item-list-filter-popover-tip .popover-header {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.65rem;
}
.item-list-filter-popover-tip .popover-body {
    padding: 0.6rem 0.65rem 0.55rem;
}
.item-filter-popover .item-filter-checks {
    max-height: 220px;
    overflow-y: auto;
    padding: 2px 0;
}
.item-filter-popover .item-filter-checks .form-check {
    padding-left: 1.6rem;
    margin-bottom: 0.1rem;
}
.item-filter-popover .item-filter-checks .form-check-label {
    line-height: 1.3;
}

/* Admin · Lookups: stacked collapsible sections */
.lookups-admin-page .lookups-admin-section .lookups-collapse-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
}

.lookups-admin-page .lookups-admin-section [data-bs-toggle="collapse"][aria-expanded="false"] .lookups-collapse-chevron {
    transform: rotate(-90deg);
}

/* Item detail · comments (chat-style thread) */
.item-comment-bubble {
    max-width: 92%;
    padding: 0.5rem 0.65rem 0.55rem;
    border-radius: 0.65rem;
    background: var(--bs-body-bg, #fff);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.item-comment-bubble--self {
    margin-left: auto;
    background: color-mix(in srgb, var(--bs-primary, #0d6efd) 12%, var(--bs-body-bg, #fff));
    border-color: color-mix(in srgb, var(--bs-primary, #0d6efd) 28%, transparent);
}

.item-comment-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.925rem;
    line-height: 1.4;
}

.item-comment-compose textarea {
    resize: vertical;
    min-height: 2.75rem;
}

.item-comment-scroll:not(.item-comment-modal-scroll) {
    max-height: 22rem;
}

/* Items list · comment thread inside modal */
.item-comment-thread--modal {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: min(70vh, 36rem);
}

.item-comment-modal-scroll {
    flex: 1 1 auto;
    min-height: 14rem;
    max-height: min(52vh, 28rem) !important;
}

/* Items list · last comment cell */
.item-list-last-comment-preview {
    max-height: 4.25rem;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.8125rem;
    line-height: 1.35;
    margin-bottom: 0.2rem;
}

.item-list-last-comment-meta {
    font-size: 0.65rem;
    line-height: 1.25;
    margin-top: 0.15rem;
}

/* ─── Permissions: per-user override matrix ────────────────────────── */
.perm-user-matrix .perm-group-title {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.7rem;
}
.perm-user-matrix .perm-group-fields {
    font-size: 0.62rem;
    line-height: 1.2;
    white-space: normal;
    max-width: 11rem;
}
.perm-user-matrix .perm-cell-select {
    font-size: 0.78rem;
}
/* Inherited (no override): subdued look so eye finds the overrides quickly. */
.perm-user-matrix .perm-cell-select.perm-cell-inherit {
    color: #6c757d;
    background-color: #f8f9fa;
    border-color: #dee2e6;
}
/* Override: amber-tinged border. */
.perm-user-matrix .perm-cell-select.perm-cell-override {
    border-color: #f0ad4e;
    background-color: #fff8e1;
    font-weight: 600;
    color: #212529;
}
.perm-user-matrix .badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.35rem;
}
.perm-user-matrix .perm-cell-reset {
    color: #6c757d;
    line-height: 1;
    text-decoration: none;
}
.perm-user-matrix .perm-cell-reset:hover {
    color: #dc3545;
}
.perm-user-matrix .perm-cell-reset svg {
    display: block;
}

/* ─── "USD Total (incl. VAT)" hover breakdown tooltip ──────────────────────
   Bootstrap tooltip styled as a dark card. The arrow inherits --bs-tooltip-bg
   so it matches the card; the visible card body is the .usdt block injected as
   HTML (see ItemService.usdTotalBreakdownHtml). */
.usd-total-tooltip {
    --bs-tooltip-max-width: 340px;
    --bs-tooltip-bg: #111827;
    --bs-tooltip-opacity: 1;
    --bs-tooltip-padding-x: 0;
    --bs-tooltip-padding-y: 0;
}
.usd-total-tooltip .tooltip-inner {
    max-width: 340px;
    padding: 0;
    background: transparent;
    text-align: left;
    box-shadow: 0 14px 34px rgba(2, 6, 23, 0.45);
    border-radius: 0.7rem;
}

.usdt {
    background: linear-gradient(160deg, #1f2937 0%, #111827 100%);
    color: #e5e7eb;
    border-radius: 0.7rem;
    padding: 0.7rem 0.8rem;
    font-size: 0.78rem;
    line-height: 1.3;
    min-width: 258px;
}
.usdt-head {
    font-weight: 700;
    font-size: 0.86rem;
    color: #fff;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.usdt-sub { font-weight: 500; color: #9ca3af; }
.usdt-row {
    padding: 0.34rem 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.09);
}
.usdt-row:last-of-type { border-bottom: none; }
.usdt-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.7rem;
}
.usdt-name { font-weight: 600; color: #cbd5e1; }
.usdt-calc { text-align: right; color: #e5e7eb; white-space: nowrap; }
.usdt-calc b { color: #fff; }
.usdt-unit { color: #9ca3af; font-size: 0.72rem; }
.usdt-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.28rem;
}
.usdt-b {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.06rem 0.42rem;
    border-radius: 999px;
    border: 1px solid transparent;
}
.usdt-b-rel { background: rgba(34, 197, 94, 0.18);  color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.usdt-b-off { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.32); }
.usdt-rownote { margin-top: 0.22rem; font-size: 0.66rem; color: #fcd34d; }
.usdt-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    padding-top: 0.42rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 700;
    color: #fff;
}
.usdt-total-val { color: #34d399; font-size: 0.98rem; }
.usdt-note { margin-top: 0.45rem; font-size: 0.66rem; color: #94a3b8; }
.usdt-warn { color: #fcd34d; }
.usdt-empty { color: #cbd5e1; padding: 0.2rem 0; }

/* ─── Who's online ─────────────────────────────────────────────── */
.online-avatar {
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    background: #6366f1;
    user-select: none;
}
/* Stable per-user palette — index computed as userId % 6 in OnlineUsersService. */
.online-avatar-c0 { background: #6366f1; }
.online-avatar-c1 { background: #0891b2; }
.online-avatar-c2 { background: #059669; }
.online-avatar-c3 { background: #d97706; }
.online-avatar-c4 { background: #db2777; }
.online-avatar-c5 { background: #7c3aed; }

/* Lets .text-truncate work on the name inside the flex row. */
.online-name-wrap { min-width: 0; }

/* Subtle highlight on the viewing user's own row. */
.online-row-current { background: #eef2ff; }

/* Pulsing green presence dot. */
.online-dot {
    flex: 0 0 auto;
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
    animation: onlinePulse 2s infinite;
}
@keyframes onlinePulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    70%  { box-shadow: 0 0 0 0.4rem rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .online-dot { animation: none; }
}

/* Sidebar live-online indicator (sits under the user card; opens the modal). */
.app-sidebar-online {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    margin-bottom: 0.6rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.7rem;
    background: #fff;
    color: #374151;
    font-size: 0.8rem;
    line-height: 1.1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.app-sidebar-online:hover,
.app-sidebar-online:focus-visible {
    background: #f0fdf4;
    border-color: #bbf7d0;
    outline: none;
}
.app-sidebar-online-text {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    min-width: 0;
}
.app-sidebar-online-count { font-weight: 700; color: #16a34a; }
.app-sidebar-online-label {
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsed rail: show just the dot + number. */
body.app-sidebar-collapsed .app-sidebar-online {
    justify-content: center;
    padding: 0.45rem;
    gap: 0.3rem;
}
body.app-sidebar-collapsed .app-sidebar-online-label { display: none; }
