/* Hide Pace.js loading bar */
.pace {
    display: none !important;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 0.85rem;
    background-color: transparent;
    padding: 0;
    height: 40px;
    line-height: 40px;
    padding-top: 5px;
    margin-bottom: 0.5rem;
}

/* Table header: no border between rows, border below filters, tighter spacing */
.table > thead > tr:first-child > th {
    vertical-align: bottom;
    border: none;
    padding-bottom: .25rem;
}

.table > thead > tr:nth-child(2) > th {
    border-top: none;
    border-bottom: none;
    padding-top: .25rem;
    padding-left: 0;
}

.table > thead > tr.filter-separator > th {
    border-top: 2px solid var(--bs-border-color);
    padding: 0;
    height: 10px;
    line-height: 0;
}

.table > tbody {
    border-top: none !important;
}

.grid-table {
    table-layout: fixed;
}

.grid-table thead th {
    font-size: 0.75rem;
    white-space: nowrap;
    vertical-align: middle;
    line-height: 1.1;
}

/* Chronology table — match edit-form font scale (form-control is 0.8rem) */
.edit-form .chronology-grid {
    font-size: 0.8rem;
}

    .edit-form .chronology-grid thead th {
        font-size: 0.75rem;
        white-space: nowrap;
        vertical-align: middle;
        line-height: 1.1;
    }

    .grid-table td:last-child {
        white-space: nowrap;
        overflow: visible;
    }

    .grid-table td a {
        cursor: pointer;
        text-decoration: none;
    }

        .grid-table td a:hover {
            opacity: 0.6;
        }

    .grid-table tr.grid-row-editable {
        cursor: pointer;
    }

    /* Compact grid scale — shared by Saldo and other long-list grids that need
       to fit more rows/columns. Apply alongside Bootstrap `table-sm`. */
    .grid-table.grid-compact {
        font-size: 0.8rem;
    }

        .grid-table.grid-compact thead th {
            font-size: 0.75rem;
            white-space: nowrap;
            vertical-align: middle;
            line-height: 1.1;
        }

    /* Stripe + hover applied deterministically on grid-table so themes
       (material's near-invisible rgba(236,239,241,0.7) striped-bg and
       default Bootstrap) can't suppress the alternating row contrast.
       Stripe targets odd rows (Bootstrap default convention) and uses
       !important to win over material's `background:` shorthand override. */
    .grid-table.table-striped > tbody > tr:nth-of-type(odd):not(.selected):not(.grid-empty-row) > * {
        --bs-table-bg-type: rgba(0, 0, 0, 0.05);
        background-color: rgba(0, 0, 0, 0.05) !important;
        background: rgba(0, 0, 0, 0.05) !important;
        box-shadow: none !important;
    }

    .grid-table.table-hover > tbody > tr:hover:not(.selected):not(.grid-empty-row) > * {
        --bs-table-bg-state: rgba(13, 110, 253, 0.10);
        background-color: rgba(13, 110, 253, 0.10) !important;
        background: rgba(13, 110, 253, 0.10) !important;
        box-shadow: none !important;
    }

.page-input {
    width: 50px;
}

.table > tbody > tr.grid-empty-row > *,
.table > tbody > tr.grid-empty-row:hover > * {
    --bs-table-bg-type: transparent;
    --bs-table-hover-bg: transparent;
    --bs-table-striped-bg: transparent;
}

/* Status cell composite (icon OR progress bar) plus breach-day overlay.
   Mirrors the WPF UgovorList_RowTemplateSelector picking between an icon
   (Canceled / Returned / Overdue) and a progress bar (active in-progress). */
.grid-table .status-cell { padding: 0.15rem 0.35rem; }
.grid-table .status-cell-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    min-height: 1.5rem;
}
/* Status text shown to the right of the icon (all states except the progress bar). */
.grid-table .status-label {
    font-size: 0.78rem;
    white-space: nowrap;
}
.grid-table .status-progress {
    width: 75%;
    height: 0.85rem;
    background-color: var(--bs-tertiary-bg);
}
.grid-table .status-breach {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.65rem;
    line-height: 1;
}

/* WPF parity (UgovorList_Window.xaml:993-1009): DatumNajamPocetak /
   DatumNajamKraj / vUgovorExtra.RacunDatumDokumentaLast paint a soft
   background when they hold a value. WPF used LightYellow; here we drive
   it through --bs-table-bg-state so the tint survives striped odd/even
   rows and the table-hover override, and it doesn't compete with row
   selection or the .table-danger flag. */
.grid-table tbody td.value-present {
    --bs-table-bg-state: rgba(13, 110, 253, 0.06);
}

/* Status grid (StrojTrenutnoStanje parity): WPF paints LightGreen on
   Dostupan = 1 and LightPink on Dostupan = 0. Drive both via
   --bs-table-bg-state so the tint stays in place under :hover and the
   striped-row alternation. */
.grid-table tbody td.status-available {
    --bs-table-bg-state: rgba(25, 135, 84, 0.18);
}
.grid-table tbody td.status-unavailable {
    --bs-table-bg-state: rgba(220, 53, 69, 0.18);
}


/* Sortable headers. Label is a normal span that follows the th's
   text-align class (text-start / text-center / text-end). The sort icon
   sits on the right edge via absolute positioning so it doesn't interfere
   with the label alignment — label can read centered or right-aligned and
   the icon still hugs the right of the cell. */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.4rem; /* leave room for the absolutely-placed icon */
}

    th.sortable .header-label {
        display: block;
    }

    th.sortable .sort-icon {
        position: absolute;
        right: 0.4rem;
        top: 50%;
        transform: translateY(-50%);
        opacity: .25;
        pointer-events: none;
    }

    th.sortable.sort-active .sort-icon {
        opacity: 1;
    }

/* Filter inputs with search icon */
input.filter-search {
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.5' cy='10.5' r='7.5'/%3E%3Cline x1='21' y1='21' x2='15.8' y2='15.8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 14px;
}

    input.filter-search:focus:placeholder-shown {
        background-image: none;
        padding-right: 12px;
    }

    input.filter-search:not(:placeholder-shown) {
        background-image: none;
    }

/* Clear button inside filter inputs */
.filter-input-wrapper {
    position: relative;
}

.filter-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    display: none;
    opacity: .4;
}

    .filter-clear:hover {
        opacity: .7;
    }

.filter-search:not(:placeholder-shown) ~ .filter-clear {
    display: block;
}

/* Compact flatpickr range input (smaller font + reduced h-padding so the selected range fits) */
input.flatpickr-range {
    padding-left: 0.3rem;
    padding-right: 0.3rem;
    font-size: 0.75rem;
    text-align: right;
}


/* Date range filter with prev/next nav arrows + presets dropdown */
.filter-date-range-nav-wrapper {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    position: relative;
}

.filter-date-range-nav-wrapper > .flatpickr-range {
    border-radius: 0;
    border-left: none;
    border-right: none;
    width: 175px;
    text-align: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Shared box-shadow/outline reset across the wrapping btn-group + each button + states */
.filter-date-range-nav-wrapper > .btn-group,
.filter-date-range-nav-wrapper > .btn-group:focus-within,
.filter-date-range-nav-wrapper > .fdn-prev,
.filter-date-range-nav-wrapper > .btn-group > .fdn-next,
.filter-date-range-nav-wrapper > .btn-group > .fdn-presets,
.filter-date-range-nav-wrapper > .fdn-prev:hover,
.filter-date-range-nav-wrapper > .btn-group > .fdn-next:hover,
.filter-date-range-nav-wrapper > .btn-group > .fdn-presets:hover,
.filter-date-range-nav-wrapper > .fdn-prev:focus,
.filter-date-range-nav-wrapper > .btn-group > .fdn-next:focus,
.filter-date-range-nav-wrapper > .btn-group > .fdn-presets:focus,
.filter-date-range-nav-wrapper > .fdn-prev:active,
.filter-date-range-nav-wrapper > .btn-group > .fdn-next:active,
.filter-date-range-nav-wrapper > .btn-group > .fdn-presets:active,
.filter-date-range-nav-wrapper > .btn-group > .fdn-presets.show {
    box-shadow: none !important;
    outline: none !important;
}

/* Padding + border only on the actual buttons, not the wrapping btn-group */
.filter-date-range-nav-wrapper > .fdn-prev,
.filter-date-range-nav-wrapper > .btn-group > .fdn-next,
.filter-date-range-nav-wrapper > .btn-group > .fdn-presets {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--bs-component-border-color);
    width: 30px;
    text-align: center;
}

.filter-date-range-nav-wrapper > .fdn-prev {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.filter-date-range-nav-wrapper > .btn-group > .fdn-next {
    border-radius: 0;
    border-right: none;
}


.filter-date-range-nav-wrapper .dropdown-menu .dropdown-item {
    padding: 0.15rem 0.75rem;
    font-size: 0.8rem;
}

.filter-date-range-nav-wrapper .dropdown-menu .dropdown-divider {
    margin: 0.15rem 0;
}

.filter-date-range-nav-wrapper > .filter-hint-icon {
    position: absolute;
    right: 67px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 11px;
    pointer-events: none;
}

.filter-date-range-nav-wrapper.has-value > .filter-hint-icon {
    display: none;
}

/* Hint icon (calendar / filter funnel) inside empty range filter inputs */
.filter-date-range-wrapper,
.filter-number-range-wrapper {
    position: relative;
}

    .filter-date-range-wrapper .filter-hint-icon,
    .filter-number-range-wrapper .filter-hint-icon {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        color: #999;
        font-size: 11px;
        pointer-events: none;
    }

    .filter-date-range-wrapper.has-value .filter-hint-icon,
    .filter-number-range-wrapper.has-value .filter-hint-icon {
        display: none;
    }

/* Number range filter (popup-based) */

    .filter-number-range-wrapper input.number-range-display {
        padding-left: 0.3rem;
        padding-right: 0.3rem;
        font-size: 0.75rem;
        text-align: right;
        cursor: pointer;
        background-color: #fff;
    }


    .filter-number-range-wrapper .number-range-popup {
        display: none;
        position: absolute;
        z-index: 1080;
        top: calc(100% + 2px);
        left: 0;
        min-width: 180px;
        padding: 6px;
        background: #fff;
        border: 1px solid var(--bs-border-color);
        border-radius: 2px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    }

    .filter-number-range-wrapper.open .number-range-popup {
        display: block;
    }

/* Compact flatpickr calendar popup */
.flatpickr-calendar {
    font-size: 0.8rem;
    width: auto;
    border-radius: 2px;
    padding: 2px;
}

    .flatpickr-calendar .flatpickr-months .flatpickr-month {
        height: 28px;
    }

    .flatpickr-calendar .flatpickr-prev-month,
    .flatpickr-calendar .flatpickr-next-month {
        height: 28px;
        padding: 0 8px;
    }

        .flatpickr-calendar .flatpickr-prev-month svg,
        .flatpickr-calendar .flatpickr-next-month svg {
            width: 12px;
            height: 12px;
        }

    .flatpickr-calendar .flatpickr-current-month {
        font-size: 0.9rem;
        padding-top: 4px;
    }

    .flatpickr-calendar .flatpickr-monthDropdown-months,
    .flatpickr-calendar .numInputWrapper {
        font-size: 0.85rem;
    }

    .flatpickr-calendar .flatpickr-monthDropdown-months {
        text-align: right;
    }

    .flatpickr-calendar .flatpickr-current-month .numInputWrapper {
        width: 7ch;
    }

    .flatpickr-calendar .flatpickr-weekday {
        font-size: 0.7rem;
    }

    .flatpickr-calendar .flatpickr-day {
        height: 28px;
        line-height: 28px;
        max-width: 32px;
        font-size: 0.8rem;
    }

    .flatpickr-calendar .dayContainer {
        min-width: 0;
        width: 224px;
        max-width: 224px;
    }

    .flatpickr-calendar .flatpickr-days {
        width: 224px;
    }

    /* Theme colors (Bootstrap primary) for selected days + range */
    .flatpickr-calendar .flatpickr-day.selected,
    .flatpickr-calendar .flatpickr-day.startRange,
    .flatpickr-calendar .flatpickr-day.endRange,
    .flatpickr-calendar .flatpickr-day.selected.inRange,
    .flatpickr-calendar .flatpickr-day.startRange.inRange,
    .flatpickr-calendar .flatpickr-day.endRange.inRange,
    .flatpickr-calendar .flatpickr-day.selected:focus,
    .flatpickr-calendar .flatpickr-day.startRange:focus,
    .flatpickr-calendar .flatpickr-day.endRange:focus,
    .flatpickr-calendar .flatpickr-day.selected:hover,
    .flatpickr-calendar .flatpickr-day.startRange:hover,
    .flatpickr-calendar .flatpickr-day.endRange:hover,
    .flatpickr-calendar .flatpickr-day.selected.prevMonthDay,
    .flatpickr-calendar .flatpickr-day.startRange.prevMonthDay,
    .flatpickr-calendar .flatpickr-day.endRange.prevMonthDay,
    .flatpickr-calendar .flatpickr-day.selected.nextMonthDay,
    .flatpickr-calendar .flatpickr-day.startRange.nextMonthDay,
    .flatpickr-calendar .flatpickr-day.endRange.nextMonthDay {
        background: var(--bs-primary);
        border-color: var(--bs-primary);
        color: #fff;
    }

    .flatpickr-calendar .flatpickr-day.inRange,
    .flatpickr-calendar .flatpickr-day.inRange.prevMonthDay,
    .flatpickr-calendar .flatpickr-day.inRange.nextMonthDay {
        background: rgba(var(--bs-primary-rgb), 0.18);
        border-color: transparent;
        box-shadow: none;
        border-radius: 0;
    }

    .flatpickr-calendar .flatpickr-day.startRange,
    .flatpickr-calendar .flatpickr-day.startRange.prevMonthDay,
    .flatpickr-calendar .flatpickr-day.startRange.nextMonthDay {
        border-radius: 2px 0 0 2px;
    }

    .flatpickr-calendar .flatpickr-day.endRange,
    .flatpickr-calendar .flatpickr-day.endRange.prevMonthDay,
    .flatpickr-calendar .flatpickr-day.endRange.nextMonthDay {
        border-radius: 0 2px 2px 0;
    }

    .flatpickr-calendar .flatpickr-day.startRange.endRange {
        border-radius: 2px;
    }

    .flatpickr-calendar .flatpickr-day.today {
        border-color: var(--bs-primary);
    }

        .flatpickr-calendar .flatpickr-day.today:hover,
        .flatpickr-calendar .flatpickr-day.today:focus {
            background: var(--bs-primary);
            border-color: var(--bs-primary);
            color: #fff;
        }

    .flatpickr-calendar .flatpickr-day:hover {
        background: rgba(var(--bs-primary-rgb), 0.08);
    }

    .flatpickr-calendar .flatpickr-monthSelect-month.selected {
        background: var(--bs-primary);
        color: #fff;
    }

    .flatpickr-calendar .flatpickr-footer {
        padding: 4px;
        border-top: 1px solid var(--bs-border-color);
    }

/* Validation summary without bullets */
.list-unstyled-nested ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

/* Global loading overlay */
#loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.4);
    z-index: 1090;
    justify-content: center;
    align-items: center;
}

    #loading-overlay.active {
        display: flex;
    }

/* Card header matches card inner border-radius */
.card > .card-header:first-child {
    border-top-left-radius: calc(var(--bs-card-border-radius) - 1px);
    border-top-right-radius: calc(var(--bs-card-border-radius) - 1px);
}

/* Tom Select control height fix (exclude header selects) */
.ts-wrapper.form-select:not(.ts-header-bg) .ts-control {
    padding: 0.375rem 0.75rem 0.4rem;
}

/* Filter-row multi-select (Tom Select) — compact + give chips enough room */
.ts-wrapper.filter-select-multi.multi .ts-control {
    min-height: 34px;
    padding: 4px 6px;
    font-size: 0.75rem;
    line-height: 1.2;
    cursor: pointer;
}

    .ts-wrapper.filter-select-multi.multi .ts-control * {
        cursor: pointer;
    }

    .ts-wrapper.filter-select-multi .ts-dropdown .option,
    .ts-wrapper.filter-select-multi .ts-dropdown .option * {
        cursor: pointer;
    }

    .ts-wrapper.filter-select-multi .ts-dropdown .option input[type="checkbox"] {
        position: relative;
        top: 2px;
    }

    /* Hide individual chips; show selected count as a single badge instead */
    .ts-wrapper.filter-select-multi.multi .ts-control > .item {
        display: none;
    }

    .ts-wrapper.filter-select-multi.multi.has-items .ts-control::before {
        content: attr(data-selected-count);
        font-size: 0.8rem;
        align-self: center;
        margin-right: 4px;
        padding-left: 4px;
        order: 2;
    }

    /* Clear-all checkbox icon (only when items selected) */
    .ts-wrapper.filter-select-multi.multi .ts-clear-all {
        display: none;
    }

    .ts-wrapper.filter-select-multi.multi.has-items .ts-clear-all {
        display: inline-block;
        color: var(--bs-primary);
        font-size: 15px;
        margin-right: 4px;
        align-self: center;
        cursor: pointer;
        order: 1;
    }



    .ts-wrapper.filter-select-multi.multi .ts-control > input {
        order: 3;
    }

.ts-wrapper.form-select-sm.multi.has-items .ts-control {
    padding-left: 12px;
    padding-bottom:0;
}

/* Tom Select with card header background */
.ts-wrapper.form-select.ts-header-bg .ts-control,
.ts-wrapper.form-select.ts-header-bg.focus .ts-control,
.ts-wrapper.form-select.ts-header-bg.dropdown-active .ts-control,
.ts-wrapper.form-select.ts-header-bg.single.input-active .ts-control {
    background-color: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.25) !important;
    box-shadow: none !important;
}

/* Subtle background for selects (Tom Select) */
.ts-wrapper.form-select.form-select-subtle {
    background-color: rgba(0, 0, 0, 0.03) !important;
    padding: 0.25rem 2.75rem 0.25rem 0.5rem !important;
    cursor: pointer;
}

    .ts-wrapper.form-select.form-select-subtle .ts-control,
    .ts-wrapper.form-select.form-select-subtle.focus .ts-control,
    .ts-wrapper.form-select.form-select-subtle.dropdown-active .ts-control {
        background-color: transparent !important;
        border: none !important;
        font-size: .8125rem;
        padding: 0.2rem 2.5rem 0.2rem 0.5rem;
        color: #6c757d;
        box-shadow: none !important;
        cursor: pointer;
        width: 100%;
    }

/* Tom Select — disable transitions for snappy search */
.ts-wrapper,
.ts-wrapper *,
.ts-dropdown,
.ts-dropdown * {
    transition: none !important;
    animation: none !important;
}

/* Tom Select dropdown_input plugin — compact search inside popup */
.ts-dropdown .dropdown-input-wrap {
    padding: 6px;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.ts-dropdown .dropdown-input {
    width: 100%;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--bs-border-radius-sm);
    background-color: #fff;
    box-shadow: none;
    outline: none;
}

.ts-dropdown .dropdown-input:focus,
.plugin-dropdown_input.focus .ts-dropdown .dropdown-input {
    border-color: rgba(13, 110, 253, 0.5);
    box-shadow: none !important;
}

/* Audit info Tom Select in dark navbar */
#audit-info-slot .ts-wrapper.form-select,
#audit-info-slot .ts-wrapper.form-select.single,
#audit-info-slot .ts-wrapper.form-select.focus,
#audit-info-slot .ts-wrapper.form-select.dropdown-active {
    background-color: rgba(255, 255, 255, 0.08) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: var(--bs-border-radius);
}

#audit-info-slot .ts-wrapper.form-select .ts-control,
#audit-info-slot .ts-wrapper.form-select.focus .ts-control,
#audit-info-slot .ts-wrapper.form-select.dropdown-active .ts-control {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
    padding: 0.2rem 2rem 0.2rem 0.5rem;
}

#audit-info-slot .ts-wrapper.form-select .ts-control .item,
#audit-info-slot .ts-wrapper.form-select .ts-control > input {
    color: rgba(255, 255, 255, 0.85) !important;
}

#audit-info-slot .ts-dropdown,
#audit-info-slot .ts-dropdown .ts-dropdown-content,
#audit-info-slot .ts-dropdown .option {
    background-color: #2c3340 !important;
    color: rgba(255, 255, 255, 0.85) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    font-size: 0.75rem;
}

#audit-info-slot .ts-dropdown .option.active,
#audit-info-slot .ts-dropdown .option:hover {
    background-color: rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
}

#audit-info-slot .text-muted {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Compact select (no Tom Select) */
.form-select-compact {
    font-size: 0.8rem;
    padding: 0.25rem 2.75rem 0.25rem 0.5rem;
    height: 30px;
}

/* Pager page input */
.page-input {
    width: 3rem !important;
    text-align: right;
}

.card-header-pills {
    padding-left:12px;
}
/* Subtle pills in card header */
.card-header-pills .nav-link.active {
    /*background-color: rgba(0, 0, 0, 0.08);*/
    background-color: transparent;
    border-radius: 0;
    border-bottom: 2px solid rgba(0, 0, 0, 0.75);
    color: #495057;
}

.card-header-pills .nav-link:not(.active):hover {
    background-color: rgba(0, 0, 0, 0.04);
}

html, body {
    overflow-x: hidden;
}

.app-content {
    padding: 0 10px;
    min-width: 0;
    overflow-x: hidden;
}

#main-page-content {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    /* The fixed app-header (60px on desktop) overlaps the document top, so
       htmx swap modifiers like `show:top` and any native scrollIntoView
       calls would otherwise hide the first ~60px of the swapped content
       (Save / Cancel button row) behind the navbar. Reserve that space via
       scroll-margin-top. */
    scroll-margin-top: 60px;
}

.table-responsive {
    max-width: 100%;
    /* Give the leftmost/rightmost cell's focus shadow room — overflow-x: auto
       on this container otherwise clips form-control:focus glow on edges. */
    padding-left: 4px;
    padding-right: 4px;
}

/* Ensure list grids stay tall enough so toolbar dropdowns and other absolutely
   positioned widgets above empty/short result sets are not clipped. Scoped via
   :has() so picker tables (.picker-table) keep their own smaller min-height. */
.table-responsive:has(.grid-table) {
    min-height: 500px;
}

/* Drop zone hint when dragging files over the attachments table. */
#attachmentsTable.drag-over {
    outline: 2px dashed var(--bs-primary);
    outline-offset: -2px;
    cursor: copy;
}

    #attachmentsTable.drag-over * {
        pointer-events: none;
    }

/* Center all cells vertically so the smaller select doesn't sit at the top
   of the row when neighbouring cells push the height up. */
#attachmentsTable tbody td {
    vertical-align: middle;
}

#attachmentsTable tbody tr {
    cursor: pointer;
}

/* Bootstrap's table-striped + table-hover already wire --bs-table-active-bg,
   but the values are too subtle on hover-strip combos. Set the variable
   explicitly so the selected row stays clearly highlighted. */
#attachmentsTable tbody tr.table-active,
#attachmentsTable tbody tr.table-active > td {
    --bs-table-active-bg: rgba(13, 110, 253, 0.22);
    --bs-table-bg-state: rgba(13, 110, 253, 0.22);
    background-color: rgba(13, 110, 253, 0.22) !important;
}

.action-header {
    margin-top: 0.25rem;
}

/* Validation errors below inputs */
.field-validation-error {
    display: block;
    padding-top: 0.25rem;
    padding-left: 0.8rem;
    margin-bottom: -0.5rem;
}

/* Red border for TomSelect with validation error */
.ts-wrapper.is-invalid .ts-control {
    border-color: var(--bs-danger) !important;
}

/* Red border for inputs with validation error */
.picker-field.is-invalid,
.form-control.is-invalid,
.form-select.is-invalid,
input.is-invalid,
.flatpickr-input.is-invalid {
    border-color: var(--bs-danger) !important;
}

/* Grid row selection — set Bootstrap's --bs-table-bg-state variable directly so
   the cell box-shadow inset (used by the table) is uniform across striped odd/even
   rows AND wins over table-danger and table-hover. Includes :hover state so the
   selection highlight is not replaced by the hover background. */
tr.grid-row-editable.selected > *,
tr.grid-row-editable.selected:hover > * {
    --bs-table-bg-state: #9ec5fe;
    color: #052c65 !important;
}

tr.grid-row-editable.selected.table-danger > *,
tr.grid-row-editable.selected.table-danger:hover > * {
    --bs-table-bg-state: #f1aeb5;
    color: #58151c !important;
}

/* Cells with their own --bs-table-bg-state (value-present in Contracts,
   status-available / status-unavailable in Machine Status) override the row
   highlight by specificity. Force the selected row's color back on these
   cells so the whole row reads as selected. */
tr.grid-row-editable.selected > td.value-present,
tr.grid-row-editable.selected:hover > td.value-present,
tr.grid-row-editable.selected > td.status-available,
tr.grid-row-editable.selected:hover > td.status-available,
tr.grid-row-editable.selected > td.status-unavailable,
tr.grid-row-editable.selected:hover > td.status-unavailable {
    --bs-table-bg-state: #9ec5fe;
}

/* Replace Bootstrap dropdown caret with Font Awesome chevron-down (clearer "has dropdown" hint). */
.dropdown-toggle::after {
    border: 0 !important;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    content: "\f078";
    font-size: 0.78em;
    vertical-align: middle;
    margin-left: 0.45em;
    line-height: 1;
}

/* Split toggle (caret-only button) — no extra left margin; button centers content. */
.dropdown-toggle.dropdown-toggle-split::after {
    margin-left: 0;
}

/* Subtle separator border between main and toggle parts of a split button group. */
.btn-group > .btn-outline-secondary.dropdown-toggle-split,
.btn-group > .btn-outline-primary.dropdown-toggle-split {
    border-left-color: rgba(0, 0, 0, 0.18);
}

/* Form row: wrapper rendered by form-field/form-select/form-bool tag helpers */
.form-row {
    margin-bottom: 1rem;
}

/* Tom Select inside a form-row matches the height/padding of native form-control */
.form-row .ts-wrapper.form-select:not(.ts-header-bg) {
    min-height: calc(1.5em + 0.4rem + var(--bs-border-width) * 2);
}

    .form-row .ts-wrapper.form-select:not(.ts-header-bg) .ts-control {
        padding: 0.2rem 0.5rem;
        min-height: 0;
        font-size: inherit;
        line-height: 1.4;
    }

        .form-row .ts-wrapper.form-select:not(.ts-header-bg) .ts-control > .item,
        .form-row .ts-wrapper.form-select:not(.ts-header-bg) .ts-control > input {
            padding: 0;
            margin: 0;
            line-height: 1.4;
            min-height: 0;
        }

/* Compact edit form: smaller fonts + tighter padding + horizontal layout */
.edit-form .form-control,
.edit-form .form-select,
.edit-form .input-group-text,
.edit-form .form-control-plaintext {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
}

.edit-form .form-label {
    font-size: 0.75rem;
    margin-bottom: 0;
    color: #6c757d;
}

.edit-form .form-check-label {
    font-size: 0.8rem;
}

.edit-form .form-row {
    margin-bottom: 0.5rem;
    display: grid;
    grid-template-columns: 9rem 1fr;
    align-items: center;
    column-gap: 0.5rem;
}

    /* Default Bootstrap .form-label has margin-bottom: 0.5rem which inflates
       the label's grid cell, leaving the label text above the vertically
       centered field (most visible against the taller picker-field). Reset
       inside form-row so align-items:center actually centers the text. */
    .edit-form .form-row > .form-label {
        margin-bottom: 0;
    }

    /* Both CSS grid items and flex items default to min-width: auto which
       refuses to shrink below their content's intrinsic size — long values
       in a picker / input-group blew the form-row's second column out
       wider than 1fr. Reset on the wrapping flex container (label sits in
       column 1 so it isn't affected) so layouts that bundle an input with
       a sibling button (DocumentNumber + Izmjeni, ContactName + info) can
       actually shrink to the grid column's allotted width. */
    .edit-form .form-row > .d-flex,
    .edit-form .form-row > .input-group {
        min-width: 0;
    }

    .edit-form .form-row > .text-danger {
        grid-column: 2;
        font-size: 0.7rem;
        margin-top: -0.2rem;
        font-weight: bold;
    }

.field-validation-error {
    display: block;
    padding-top: 0.25rem;
    padding-left: 0.8rem;
    margin-bottom: -0.2rem;
}

/* Red border on controls with a validation error. `input-validation-error` is
   added server-side on ModelState errors and client-side by jQuery unobtrusive.
   Native inputs/selects/textarea carry it directly; wrapped controls (TomSelect,
   picker-field) carry it on the hidden/original element, so we colour the visible
   sibling instead. */
.edit-form .input-validation-error {
    border-color: var(--bs-danger);
}

    .edit-form .input-validation-error:focus {
        border-color: var(--bs-danger);
        box-shadow: 0 0 0 0.25rem rgba(var(--bs-danger-rgb), .25);
    }

/* Wrapped/custom controls (TomSelect, picker-field) don't reliably get
   input-validation-error on their VISIBLE element — the class lands on the hidden
   <select>/<input> (which jQuery's :hidden filter also skips). Detect the error
   from the validation message span instead: .field-validation-error is set both
   server-side and client-side, and is a direct child of the .form-row. :has() lets
   us reach back to colour the visible control regardless of how it's nested
   (e.g. the work-order Klijent picker sits inside a .d-flex within the row). */
.edit-form .form-row:has(> .field-validation-error) .picker-field,
.edit-form .form-row:has(> .field-validation-error) .ts-control {
    border-color: var(--bs-danger);
}

.edit-form .card-body {
    padding: 0.6rem 0.75rem;
}

/* Utility: pointer cursor on hover (e.g. tooltip-bearing icons that read as
   interactive). Bootstrap ships no cursor utility by default. */
.cursor-pointer {
    cursor: pointer;
}

/* Compact button that sits inline with a form input (e.g., DocumentNumber
   "Izmjeni" pen, contact picker info icon). Tight padding to match the
   input's height; no shadow so it doesn't compete visually with the
   surrounding field. */
.form-inline-button {
    padding: 0 0.5rem;
    line-height: 23px;
    box-shadow: none !important;
}

    .form-inline-button:focus,
    .form-inline-button:active {
        box-shadow: none !important;
    }

.edit-form .tabs-card .card-body {
    padding: 0.75rem 1rem;
}

/* Reserve a stable height for the tab content area so switching between
   the Kalkulacija / Ostali podaci / Razrada / Kršenje / Dokumenti tabs
   doesn't cause the rest of the page to jump around. */
.edit-form .tabs-card .tab-content {
    min-height: 600px;
}

.edit-form .card-header:not(.tabs-header) {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
}

/* Outer "tab" card hosting inner cards — strip border + body bg so the inner
   cards stand on their own, and darken the header so the tab nav is visually
   separated from the card-header style used inside. */
.tab-with-cards,
.tab-with-cards > .card-header:first-child,
.tab-with-cards > .card-body:last-child,
.tab-with-cards > .card-header,
.tab-with-cards > .card-body {
    border-radius: 0;
}

.tab-with-cards {
    border: 0;
}

    .edit-form .tab-with-cards > .card-body {
        background-color: var(--bs-body-bg);
        padding-inline: 0;
    }

    .tab-with-cards > .card-header {
        background-color: var(--bs-gray-200);
        color: var(--bs-gray-900);
    }

        .tab-with-cards > .card-header .nav-link {
            color: var(--bs-gray-900);
        }

.calc-prices thead th {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--bs-secondary-color);
    border-bottom: 1px solid var(--bs-border-color);
    padding: 0.15rem 0.25rem;
}

.calc-prices tbody td {
    padding: 0.15rem 0.25rem;
    font-size: 0.8rem;
    vertical-align: middle;
    border-top: 0;
    border-bottom: 0;
}

.calc-prices tbody tr.calc-row-total td {
    border-top: 1px solid var(--bs-border-color);
}

    .calc-prices tbody td:first-child {
        white-space: nowrap;
    }

.calc-prices .form-control-sm {
    font-size: 0.8rem;
    padding: 0.15rem 0.35rem;
    min-width: 70px;
}

/* Picker-field display text: ellipsis-truncate so a long contact name
   doesn't overflow the column when it sits next to a sibling button. */
.picker-field {
    min-width: 0;
}

.picker-field-display {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Picker field readonly state — used when the parent form is in a
   business-locked or history-view mode (Model.IsReadOnly / IsContractLocked).
   The hidden input still posts the current value back. */
.picker-field-disabled {
    background-color: var(--bs-component-disabled-bg);
    color: var(--bs-body-color);
    cursor: not-allowed;
    pointer-events: none;
    opacity: 1;
}

.form-select:disabled {
    background-color: var(--bs-component-disabled-bg);
    opacity: 1;
}

.input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
}

.input-group:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
}

/* Toolbar grouping helper: 10px extra slot on the left of a button that
   starts a new logical group inside a flex toolbar. */
.btn-group-start {
    margin-left: 10px;
}

/* Square 30x30 icon-only secondary toolbar button. The .btn compound bumps
   specificity to (0,2,0) so it beats vendor `.btn:not(.btn-link)` (box-shadow)
   in material/app.min.css — site.css loads after it, so equal specificity wins. */
.btn.toolbar-btn-secondary {
    width: 30px;
    height: 30px;
    padding: 0;
    box-shadow: none;
}

/* Fleet summary — wider gaps between columns (table keeps its full width). */
.summary-table > thead > tr > *,
.summary-table > tbody > tr > *,
.summary-table > tfoot > tr > * {
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Equal-width metric columns (Contracts / Open work orders) regardless of the
   header text length; the longer header wraps within the fixed width. */
.summary-table th.summary-metric {
    width: 11rem;
    white-space: normal;
}

/* Branch report has many columns and no card max-width — keep it content-sized
   so the first (label) column doesn't stretch to absorb the leftover width. */
table.branch-summary {
    width: auto;
}

/* count + percent as two fixed-width sub-columns so the percentages line up
   neatly down each metric column. */
.summary-table .summary-count {
    display: inline-block;
    min-width: 3.5rem;
    text-align: right;
}

.summary-table .summary-pct {
    display: inline-block;
    min-width: 3.5rem;
    text-align: right;
}

/* Subtle utilization bar under the numbers, filling right-to-left. Half the cell
   width, kept to the right (margin-left auto). */
.summary-table .summary-bar {
    height: 3px;
    width: 70%;
    margin-left: auto;
    background: rgba(0, 0, 0, .06);
    border-radius: 2px;
    overflow: hidden;
    display: flex;
    justify-content: flex-end;
}

.summary-table .summary-bar-fill {
    height: 100%;
    background: rgba(13, 110, 253, .35);
    border-radius: 2px;
}

/* Header — matching breathing room below it. Selector mirrors (and beats on
   specificity) the global `.table > thead > tr:first-child > th` rule. */
.table.summary-table > thead > tr:first-child > th {
    padding-bottom: 1rem;
}

/* Totals ("Ukupno") row — no border, extra breathing room above it. */
.summary-table > tfoot > tr > * {
    border: 0;
    padding-top: 0.9rem;
}

/* Toasts must sit above open modals (Bootstrap modal z-index = 1055) so a
   validation toast fired while a dialog is open (e.g. return-date error) stays
   visible instead of rendering behind the modal. */
#toast-container {
    z-index: 1090;
}

/* Contracts grid bottom detail drawer (WPF UgovorList master-detail) — a
   hideable bottom overlay that loads the selected contract's related records.
   Slides up on row select, closes via the header button. */
.contract-detail-drawer {
    position: fixed;
    /* Respect the collapsible theme sidebar — mirror .app-content's margin-left
       (220px desktop, 60px minified, 0 mobile) so the drawer starts at the grid. */
    left: 220px;
    right: 0;
    bottom: 0;
    height: 45vh;
    background: #fff;
    border-top: 1px solid var(--bs-border-color);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .12);
    transform: translateY(100%);
    transition: transform .25s ease, left .15s ease;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-sidebar-minified .contract-detail-drawer {
    left: 60px;
}

@media (max-width: 767.98px) {
    .contract-detail-drawer {
        left: 0;
    }
}

.contract-detail-drawer.open {
    transform: translateY(0);
}

/* Top drag handle — vertical resize. Overlaid on the header's top edge (absolute,
   out of flow) so it doesn't push the title/collapse button off-centre; just a
   grip line over the dark header. */
.contract-detail-resize {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    z-index: 2;
}

.contract-detail-resize::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .35);
}

.contract-detail-resize:hover::after {
    background: rgba(255, 255, 255, .65);
}

#contract-detail-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.contract-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: #495057;
    color: #fff;
    flex: 0 0 auto;
}

.contract-detail-collapse {
    border: 0;
    background: transparent;
    color: inherit;
    opacity: .85;
    padding: .15rem .4rem;
    line-height: 1;
    cursor: pointer;
}

.contract-detail-collapse:hover {
    opacity: 1;
}

.contract-detail-tabs {
    flex: 0 0 auto;
    padding: .35rem .5rem 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.contract-detail-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 1rem;
    background-color: var(--bs-body-bg);
}

.contract-detail-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 8rem;
    font-style: italic;
}

/* Work-order list status indicator (WPF RadniNalogList row colouring). */
.work-orders-grid .status-dot {
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}

/* Work-order "Ostali podaci" datetime fields — fixed narrow width. flatpickr
   copies the input's className to its visible altInput, so the class (not an
   inline style, which isn't copied) reaches the rendered control. */
.wo-date-w {
    width: 130px !important;
}

/* Preserve newlines (\n and \r\n) in text such as the contact saldo note,
   which is plain text entered with line breaks. pre-wrap keeps the breaks and
   still wraps long lines. Used via class="text-pre-wrap" in the views. */
.text-pre-wrap {
    white-space: pre-wrap;
}

/* Cards sit a touch off-white instead of stark white — the component bg tinted
   slightly toward the theme body colour (blue-grey in light, deeper in dark) so
   they stay in keeping with the Material theme in both modes. If a browser
   doesn't support color-mix the declaration is ignored and cards fall back to
   the theme default, so there's no broken state. */
.card {
    --bs-card-bg: color-mix(in srgb, var(--bs-component-bg) 65%, var(--bs-body-bg));
}

/* Audit history navigator sizing. No alert palette for viewing-history —
   the select keeps its default navbar styling so dropdown options stay
   readable; the X/Y counter on its own communicates the position. */
.audit-nav .audit-nav-select {
    min-width: 18rem;
    max-width: 22rem;
}
