.floating-labels .field-show-floating-label .field-label {
    -webkit-transform: none;
    transform: none;
    opacity: 1;
    z-index: 3;
}

    .floating-labels .field-show-floating-label .field-label.required {
        background: transparent url(../../images/icons/required.png) no-repeat right;
        color: #b94a48;
        padding-right: 13px;
    }

.floating-labels .field-show-floating-label .field-input {
    padding-top: 1.5em;
    padding-bottom: 0.35714em;
}

/* field-static-floating-label — the label is always docked above the
   input, regardless of whether the field has a value. The C# helper
   (e.g. FloatingLabelMilitaryDateTimePicker) sets this class together
   with field-show-floating-label on render; the per-module sync JS
   that strips field-show-floating-label on empty fields shouldn't
   take this class with it. Without these rules the label inherits
   .field-label's default opacity:0 and disappears whenever the field
   is empty. Mirrors the field-show-floating-label ruleset. */
.floating-labels .field-static-floating-label .field-label {
    -webkit-transform: none;
    transform: none;
    opacity: 1;
    z-index: 3;
}

    .floating-labels .field-static-floating-label .field-label.required {
        background: transparent url(../../images/icons/required.png) no-repeat right;
        color: #b94a48;
        padding-right: 13px;
    }

.floating-labels .field-static-floating-label .field-input,
.floating-labels .field-static-floating-label .field-time,
.floating-labels .field-static-floating-label .field-date {
    padding-top: 1.5em;
    padding-bottom: 0.35714em;
}

.floating-labels .field-label,
.floating-labels .field-input {
    -webkit-transition: all 0.2s ease-out;
    transition: all 0.2s ease-out;
}

.floating-labels .field {
    width: 100%;
    float: left;
    padding: 0.42857em 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.floating-labels .field-input-wrapper {
    position: relative;
}

    .floating-labels .field-input-wrapper.field-border {
        border-color: #d9d9d9;
        border-width: 1px;
        border-style: solid;
        border-radius: 5px;
    }

    .floating-labels .field-input-wrapper.readonly,
    .floating-labels .field.disabled .field-input-wrapper {
        background-color: #eeeeee;
    }

.floating-labels .field-label {
    font-size: 0.88em;
    font-weight: normal;
    position: absolute;
    top: 0;
    width: auto;
    margin-top: 0.42857em;
    margin-left: 1px;
    padding: 0 0.91667em;
    z-index: 1;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-transform: translateY(3px);
    transform: translateY(3px);
    pointer-events: none;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    opacity: 0;
    color: #737373;
    display: block;
    text-align: left;
    margin: 0.5em 0;
    overflow: hidden;
    max-width: calc(100% - 7px);
}

.floating-labels .field-input {
    background-color: #FFFFFF;
    color: #333333;
    border-color: #d9d9d9;
    border-width: 1px;
    border-style: solid;
    background-clip: padding-box;
    border-radius: 5px;
    display: block;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    width: 100%;
    padding: 0.92857em 0.78571em;
    word-break: normal;
    line-height: inherit;
}

    .floating-labels .field-input.field-input-checkbox:has(input:focus) {
        border-color: #64b0f2;
        -webkit-box-shadow: 0 0 0 1px #64b0f2;
        box-shadow: 0 0 0 1px #64b0f2;
        background-clip: padding-box;
        border-radius: 5px;
        border-style: solid;
        border-width: 1px;
        white-space: nowrap;
        overflow: hidden;
    }

    .floating-labels .field-input[disabled],
    .floating-labels .field-input[readonly],
    .floating-labels .field-input.readonly,
    .floating-labels .field-time.readonly,
    .floating-labels .field-date.readonly {
        background-color: #eee;
    }

        .floating-labels .field-input.readonly > label {
            color: #737373;
        }

    .floating-labels .field-input.required::placeholder {
        color: #b94a48;
    }

/* ===== Dropdown placeholder->float (label-as-placeholder) =====
   A <select> has no native placeholder, so an empty .field-select shows its own
   label in the placeholder position and floats it up on selection (shared.js /
   the framework initFloatingLabels toggle field-show-floating-label). The
   required.png marker sits right after the label text, same as the floated state.

   Both states also test the selection directly via :has(option:checked), not just
   the JS class. A dropdown populated by AJAX after initFloatingLabels has run gets
   its value through jQuery .val(), which fires no change event, so the class never
   lands and the label would otherwise sit on top of the selected text.

   "A real selection" needs BOTH tests. A placeholder is usually rendered as
   value="", but not always: FloatingLabelDropDownListExtensions only emits a
   value attribute when SelectListItem.Value is non-null, so the common
   `list.Insert(0, new())` placeholder comes out as a bare <option></option>
   with no attribute at all. That passes :not([value=""]) and floated the label
   on a dropdown the user had not touched - Category did this while Subcategory,
   which is populated by AJAX and so starts with no options, correctly showed
   its label large. :not(:empty) covers that shape, and still floats an option
   that carries text but no value attribute, which submits its text as the
   value and IS a real selection.

   Scoped to :not(:has(.ts-wrapper)) so this only ever drives native dropdowns. A
   Tom Select field keeps its underlying <select> in sync, so it would match too -
   and floating its label while the autocomplete pilot rule below still has the
   .ts-control in placeholder mode (no reserved top padding, transparent) would
   reintroduce the very overlap this fixes. The pilot owns that state. */
.floating-labels .field-select:not(:has(.ts-wrapper)):has(select option:checked:not([value=""]):not(:empty)) .field-label {
    -webkit-transform: none;
    transform: none;
    opacity: 1;
    top: 0;
    margin: 0.5em 0;
    font-size: 0.88em;
    z-index: 3;
}

.floating-labels .field-select:not(:has(.ts-wrapper)):has(select option:checked:not([value=""]):not(:empty)) .field-input {
    padding-top: 1.5em;
    padding-bottom: 0.35714em;
}

.floating-labels .field-select:not(.field-show-floating-label):not(.field-static-floating-label) .field-label {
    opacity: 1;
    top: 50%;
    margin: 0;
    width: auto;
    max-width: calc(100% - 2.4em);
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    font-size: 1em;
    color: #737373;
}

    .floating-labels .field-select:not(.field-show-floating-label):not(.field-static-floating-label) .field-label.required {
        background: transparent url(../../images/icons/required.png) no-repeat right;
        color: #b94a48;
        padding-right: 13px;
    }

    /* A disabled dropdown shouldn't advertise as required. */
    .floating-labels .field-select:not(.field-show-floating-label):has(select:disabled) .field-label.required {
        background: none;
        color: #737373;
        padding-right: 0;
    }

/* ===== Required text inputs / textareas: label-as-placeholder =====
   Tagged .field-ph by initFloatingLabels. The field's own label plays the
   placeholder role while empty (the required.png marker sits right after the
   text) and floats up on value — matching the dropdown placeholder->float. The
   native placeholder is hidden so it doesn't double the text. */
.floating-labels .field-ph:not(.field-show-floating-label) .field-input::placeholder {
    color: transparent;
}

.floating-labels .field-ph:not(.field-show-floating-label) .field-label {
    opacity: 1;
    margin: 0;
    width: auto;
    max-width: calc(100% - 0.5em);
    font-size: 1em;
    color: #737373;
}

    /* single-line inputs: label vertically centred like a placeholder */
    .floating-labels .field-ph-input:not(.field-show-floating-label) .field-label {
        top: 50%;
        -webkit-transform: translateY(-50%);
        transform: translateY(-50%);
    }

    /* textareas: label docked at the top-left, where the first line begins */
    .floating-labels .field-ph-textarea:not(.field-show-floating-label) .field-label {
        top: 0;
        margin-top: 0.92857em;
        -webkit-transform: none;
        transform: none;
    }

    /* required + empty: red label with the required.png marker right after the text */
    .floating-labels .field-ph:not(.field-show-floating-label) .field-label.required {
        background: transparent url(../../images/icons/required.png) no-repeat right;
        color: #b94a48;
        padding-right: 13px;
    }

/* ===== Readonly / disabled placeholder fields =====
   The placeholder->float above is driven by BaseFloatingLabelControl adding
   field-show-floating-label on focus / input / blur. A readonly or disabled
   input receives none of those events, so a value rendered server-side left the
   label parked in the centred placeholder slot - printed directly on top of the
   value. Seen on the Edit Barge dialog's Tracking Mode box
   (@Html.FloatingLabelTextBoxFor(..., new { @readonly = "readonly" })), where
   the label sat over "Both".

   There is nothing to type into these, so the label docks permanently - the
   same treatment field-static-floating-label gives, but applied from the
   control's state instead of asking every call site to remember the class. */
.floating-labels .field-ph:has(> .field-input-wrapper > .field-input[readonly]) .field-label,
.floating-labels .field-ph:has(> .field-input-wrapper > .field-input:disabled) .field-label {
    top: 0;
    margin: 0.5em 0;
    max-width: calc(100% - 7px);
    font-size: 0.88em;
    -webkit-transform: none;
    transform: none;
    opacity: 1;
    z-index: 3;
}

.floating-labels .field-ph:has(> .field-input-wrapper > .field-input[readonly]) .field-input,
.floating-labels .field-ph:has(> .field-input-wrapper > .field-input:disabled) .field-input {
    padding-top: 1.5em;
    padding-bottom: 0.35714em;
}

    /* disabled required text field shouldn't advertise as required */
    .floating-labels .field-ph:not(.field-show-floating-label):has(.field-input:disabled) .field-label.required {
        background: none;
        color: #737373;
        padding-right: 0;
    }

    .floating-labels .field-input:focus {
        outline: none;
        border-color: #64b0f2;
        -webkit-box-shadow: 0 0 0 1px #64b0f2;
        box-shadow: 0 0 0 1px #64b0f2;
    }


    .floating-labels .field-input.datePickerInput {
        display: inline-block;
        width: 100% !important;
        padding-right: 30px;
    }

/* Collapse the flatpickr wrap div from layout so the calendar trigger
   can be absolutely positioned within .field-input-wrapper. The wrap
   div is added by flatpickr's wrap-mode and otherwise stacks the
   trigger below the input as a block-level child. */
.floating-labels .field-input-wrapper > .flatpickr {
    display: contents;
}

.floating-labels .flatpickr-trigger,
.floating-labels .field-input-wrapper .ui-datepicker-trigger {
    position: absolute;
    top: 12px;
    right: 7px;
}

/* When the underlying date input is readonly, the input and the calendar
   trigger should look and behave inert. flatpickrUtil.setEnabled also
   sets clickOpens: false, so this is the visual half of that contract
   and a defensive guard for trigger clicks that bypass clickOpens. */
.flatpickr > .flatpickr-input[readonly] {
    cursor: default;
}
.flatpickr > .flatpickr-input[readonly] ~ .flatpickr-trigger {
    cursor: default;
    pointer-events: none;
}
.flatpickr > .flatpickr-input[readonly] ~ .flatpickr-trigger img {
    cursor: default;
    pointer-events: none;
    opacity: 0.4;
}

/* When the underlying date input is readonly, the calendar trigger
   should look and behave inert. flatpickrUtil.setEnabled also sets
   clickOpens: false, so this is the visual half of that contract and
   a defensive guard for trigger clicks that bypass clickOpens. */
.flatpickr > .flatpickr-input[readonly] ~ .flatpickr-trigger,
.flatpickr > .flatpickr-input[readonly] ~ .flatpickr-trigger img {
    cursor: default;
    pointer-events: none;
}

.floating-labels .field-input-select {
    background-color: transparent;
    padding-right: 2.07143em;
    white-space: nowrap;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    -webkit-font-smoothing: inherit;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

    .floating-labels .field-input-select[disabled] {
        cursor: default;
    }

.floating-labels .embedded-link {
    position: absolute;
    top: 0;
    right: 25px;
    font-size: 0.88em;
    padding: 0 0.91667em;
    margin: 0.5em 0;
    z-index: 3;
}

.floating-labels .field-caret {
    border-left: 1px rgba(179,179,179,0.5) solid;
    display: block;
    width: 2.14286em;
    height: 43%;
    position: absolute;
    top: 50%;
    right: 0;
    -webkit-transform: translate(0%, -50%);
    transform: translate(0%, -50%);
    text-align: center;
    color: #919191;
    cursor: pointer;
    z-index: 1;
}

.floating-labels select.field-input[disabled] + .field-caret {
    cursor: default;
}

/* Tom Select inside a floating-label wrapper: the framework's .field-caret
   already renders a chevron with its own click handler, so suppress
   Tom Select's CSS caret to avoid a duplicate. */
.floating-labels .field-input-wrapper .ts-wrapper.single .ts-control::after {
    display: none;
}

/* Size the Tom Select control to match .field-input so the autocomplete
   renders at the same height it did before the Selectize → Tom Select
   migration. Extra top padding leaves room for the floating label. */
.floating-labels .field-input-wrapper .ts-control {
    border-color: #d9d9d9;
    border-radius: 5px;
    padding: 1.5em 2.07143em 0.35714em 0.78571em;
    line-height: inherit;
}

    /* Autocomplete placeholder->float pilot: while the autocomplete has no value
       (and isn't focused — FloatingLabelAutoComplete floats
       field-show-floating-label on focus/value), drop the reserved top padding so
       the label reads as a centred placeholder (positioned by the .field-select
       rule above) rather than floating above an empty gap. */
    .floating-labels .field-select:not(.field-show-floating-label) .field-input-wrapper .ts-control {
        padding-top: 0.92857em;
        padding-bottom: 0.92857em;
        /* Tom Select paints an opaque white .ts-control in its own stacking
           context, later in the DOM than the label, so it would cover the
           placeholder-mode label. The native <select> variant avoids this by
           being transparent (.field-input-select); mirror that here so the
           label shows through as the placeholder. On focus/value
           field-show-floating-label drops this rule and the control paints
           its normal white background again. */
        background: transparent;
    }

.floating-labels .field-input-wrapper .ts-wrapper.focus .ts-control {
    border-color: #64b0f2;
    box-shadow: 0 0 0 1px #64b0f2;
}

/* Multi-select pills overlap the floating label without this. The Bootstrap
   4 Tom Select theme writes a `padding` shorthand on .ts-wrapper.multi.has-items
   .ts-control (specificity 0,4,0) which clobbers the 1.5em top padding set
   above. Bump specificity (5 classes) and re-apply the top/bottom/right
   spacing while preserving the framework's narrower left padding for pill
   layout. */
.floating-labels .field-input-wrapper .ts-wrapper.multi.has-items .ts-control {
    padding-top: 2em;
    padding-right: 2.07143em;
    padding-bottom: 0.35714em;
}

.field-time-picker > .field-input-wrapper {
    border-color: #d9d9d9;
    background-clip: padding-box;
    border-radius: 5px;
    border-style: solid;
    border-width: 1px;
    white-space: nowrap;
    overflow: hidden;
}

    .field-time-picker > .field-input-wrapper:has(input:focus) {
        border-color: #64b0f2;
        -webkit-box-shadow: 0 0 0 1px #64b0f2;
        box-shadow: 0 0 0 1px #64b0f2;
    }

    .field-time-picker > .field-input-wrapper .field-time {
        padding-top: 1.5em;
        padding-bottom: .35714em;
        width: 65px !important;
        border-left: 0;
        border-right: 0;
        border-top: 0;
        padding-right: 0;
        border-bottom: 0;
        padding-left: 0.78571em;
        display: inline-block;
    }

    .field-time-picker > .field-input-wrapper .field-date {
        padding-top: 1.5em;
        padding-bottom: .35714em;
        width: calc(100% - 65px) !important;
        border-left: 0;
        border-right: 0;
        border-top: 0;
        border-bottom: 0;
        padding-left: 0;
        display: inline-block;
        -webkit-box-shadow: none;
        box-shadow: none;
    }

    /* The flatpickr wrap-mode div sits between .field-input-wrapper and
       the date input. Collapse it from layout so the date / time inputs
       render side-by-side as if they were direct children. */
    .field-time-picker > .field-input-wrapper > .flatpickr {
        display: contents;
    }

    .field-time-picker > .field-input-wrapper .field-time.input-validation-error {
        border-right: none !important;
    }

    .field-time-picker > .field-input-wrapper .field-date.input-validation-error {
        border-left: none !important;
    }

    .floating-labels .list-horizontal > .list-item {
        display: inline-block;
        margin-top: 5px;
        margin-right: 5px;
    }

    .floating-labels .list-horizontal > .list-item > label,
    .floating-labels .list-vertical > .list-item > label {
        font-weight: normal;
    }

        .floating-labels .list-vertical > .list-item > input[type="radio"] + label,
        .floating-labels .list-vertical > .list-item > label + input[type="radio"],
        .floating-labels .list-horizontal > .list-item > input[type="radio"] + label,
        .floating-labels .list-horizontal > .list-item > label + input[type="radio"] {
            margin-left: 3px;
        }

.floating-labels .list-vertical > .list-item {
    display: block;
    margin-top: 3px;
}

    .floating-labels .list-vertical > .list-item:first-child {
        display: block;
        margin-top: 5px;
    }

/* ===== Tom Select (autocomplete) fields: float from the control's own state =====
   The floated / placeholder state of an autocomplete was driven only by the
   field-show-floating-label class, and two scripts fight over that class:
   FloatingLabelAutoComplete sets it from the selected value, but
   core.ui.initFloatingLabels() - which every lazily loaded dialog calls again -
   also binds Tom Select's inner search <input type="text"> as if it were a text
   field. Its blur handler (and initLabels on every later call) clears the class
   whenever the SEARCH box is empty, which it always is once an option has been
   picked. The label then dropped back into the centred placeholder slot,
   printed straight over the chosen value; seen on the Add Barges dialog's
   Customer / Commodity / Origin fields.

   Tom Select already reports the facts that matter on its wrapper: .has-items
   (a value is selected) and .focus (the user is typing). Float on those so the
   label is right whichever script touched the class last. Specificity beats the
   placeholder-mode rules above (.field-select:not(...) / .field-ph:not(...)). */
.floating-labels .field-select:has(.ts-wrapper.has-items) .field-label,
.floating-labels .field-select:has(.ts-wrapper.focus) .field-label {
    top: 0;
    margin: 0.5em 0;
    max-width: calc(100% - 7px);
    font-size: 0.88em;
    -webkit-transform: none;
    transform: none;
    opacity: 1;
    z-index: 3;
}

.floating-labels .field-select:has(.ts-wrapper.has-items) .field-input-wrapper .ts-control,
.floating-labels .field-select:has(.ts-wrapper.focus) .field-input-wrapper .ts-control {
    padding-top: 1.5em;
    padding-bottom: 0.35714em;
    background-color: #FFFFFF;
}

/* One caret on a floating-label autocomplete.
   framework-controls.css suppresses the Bootstrap 5 tom-select skin's chevron
   (a background-image on .ts-control) in favour of the framework's .field-caret,
   but with a selector of the SAME specificity - and the Inventory, Railcar,
   FieldInspection and VesselLoading pages link tom-select.bootstrap5.css from
   their own `styles` section, i.e. after the shell CSS, so the skin won and both
   carets showed (hidden only while the field was empty, because the
   placeholder-mode rule happens to set `background: transparent`). These fields
   always carry a .field-caret, so drop the skin's chevron here with a selector
   that outranks the skin wherever it is linked. Grid editors are untouched:
   they render with appendCaret = false and keep the skin's chevron as their
   only caret. */
.floating-labels .field-input-wrapper .ts-wrapper.single .ts-control {
    background-image: none;
}