/* Audited JSF query cohorts. Presentation only: legacy screens never receive
   these classes. Keep business colors, validation states and numeric alignment. */
body.emro-app-shell .emro-query-heading,
body.emro-app-shell .emro-query-workbench {
    --emro-color-action: #4f46e5;
    --emro-color-action-hover: #4338ca;
    --emro-color-action-soft: #eef2ff;
    font-family: var(--emro-font-family);
    min-width: 0;
}

body.emro-app-shell .emro-query-heading {
    padding: 0.75rem 1rem 0.625rem;
    color: var(--emro-color-text);
}

body.emro-app-shell .emro-query-heading h1 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.2;
    font-weight: 700;
}

body.emro-app-shell .emro-query-heading .emro-query-eyebrow {
    margin: 0 0 0.125rem;
    color: var(--emro-color-action);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body.emro-app-shell .emro-query-heading .emro-query-subtitle {
    margin: 0.25rem 0 0;
    max-width: 80ch;
    color: var(--emro-color-text-muted);
    font-size: 0.8125rem;
}

body.emro-app-shell .emro-query-workbench > .ui-tabs-panels > .ui-tabs-panel,
body.emro-app-shell .emro-query-results-section {
    padding: 0.75rem 1rem;
}

body.emro-app-shell .emro-query-workbench .emro-query-search {
    display: grid;
    gap: 0.625rem;
    min-width: 0;
}

body.emro-app-shell .emro-query-workbench .emro-query-primary {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.75rem;
    min-width: 0;
}

body.emro-app-shell .emro-query-workbench .emro-query-field-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(9rem, 1fr));
    gap: 0.5rem 0.75rem;
    min-width: 0;
}

body.emro-app-shell .emro-query-workbench .emro-query-primary-fields {
    flex: 1 1 42rem;
    grid-template-columns: minmax(13rem, 1.5fr) repeat(3, minmax(9rem, 1fr));
}

body.emro-app-shell .emro-query-workbench .emro-query-field {
    min-width: 0;
}

/* DataWindow renderers retain their Bootstrap/inline wrappers and listeners.
   The explicit field wrapper provides grid geometry for their first two divs. */
body.emro-app-shell .emro-query-workbench .emro-query-field > div,
body.emro-app-shell .emro-query-workbench .emro-query-field > div > div {
    float: none;
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    padding: 0;
    margin-inline: 0;
}

body.emro-app-shell .emro-query-workbench .emro-query-field .ui-outputlabel {
    font-size: 0.875rem !important;
    font-weight: 600;
}

/* Primary searches match the approved reference. Secondary filters, forms and
   table editors retain their own renderer geometry. */
body.emro-app-shell .emro-full-workbench .emro-query-primary {
    container-type: inline-size;
    container-name: emro-primary-search;
}

body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields {
    display: grid;
    flex: 1 1 42rem;
    grid-template-columns: minmax(13rem, 1.5fr) repeat(3, minmax(9rem, 1fr));
    gap: 0.5rem 0.75rem;
    min-width: 0;
    margin: 0;
}

/* Bootstrap's row clearfix would otherwise occupy two extra grid cells. */
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields.row::before,
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields.row::after {
    display: none;
    content: none;
}

body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .emro-full-field {
    display: block;
    width: 100%;
    min-width: 0;
}

/* A native hidden or absent renderer must not leave an empty primary cell. */
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .emro-full-field:not(:has(> div)),
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .emro-full-field:has(> div > div[style*="display: none"]),
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .emro-full-field:has(> div > div[style*="display:none"]) {
    display: none;
}

body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .emro-full-field > div,
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .emro-full-field > div > div {
    float: none;
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    padding: 0;
    margin-inline: 0;
}

/* Native column metadata may supply an inline bold weight. */
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .ui-outputlabel {
    display: inline-block;
    max-width: 100%;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.25;
}

body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .ui-inputfield,
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .ui-selectonemenu,
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .ui-selectcheckboxmenu,
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .ui-inputnumber,
body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields .ui-calendar {
    width: 100% !important;
    max-width: 100%;
}

body.emro-app-shell .emro-query-workbench .ui-inputfield,
body.emro-app-shell .emro-query-workbench .ui-selectonemenu,
body.emro-app-shell .emro-query-workbench .ui-selectcheckboxmenu,
body.emro-app-shell .emro-query-workbench .ui-inputnumber,
body.emro-app-shell .emro-query-workbench .ui-calendar {
    font-size: 1rem !important;
    line-height: normal;
    box-sizing: border-box;
}

body.emro-app-shell .emro-query-workbench input.ui-inputfield {
    min-height: var(--emro-control-height);
    height: auto !important;
    padding-top: 4px;
    padding-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

body.emro-app-shell .emro-query-workbench .emro-query-field .ui-inputfield,
body.emro-app-shell .emro-query-workbench .emro-query-field .ui-selectonemenu,
body.emro-app-shell .emro-query-workbench .emro-query-field .ui-selectcheckboxmenu,
body.emro-app-shell .emro-query-workbench .emro-query-field .ui-inputnumber,
body.emro-app-shell .emro-query-workbench .emro-query-field .ui-calendar {
    width: 100% !important;
    max-width: 100%;
}

/* Normalize the whole composite widget once; inner inputs own their padding.
   Multi-value checkbox menus and textareas may grow to show their contents. */
body.emro-app-shell .emro-query-workbench .ui-selectonemenu,
body.emro-app-shell .emro-query-workbench .ui-selectcheckboxmenu {
    min-height: var(--emro-control-height);
    height: auto !important;
    padding: 0;
}

body.emro-app-shell .emro-query-workbench .ui-selectonemenu .ui-selectonemenu-label {
    min-height: 0;
    height: auto;
    padding: 4px 0.5rem;
    border: 0;
    line-height: normal;
}

body.emro-app-shell .emro-query-workbench .ui-selectonemenu .ui-selectonemenu-trigger,
body.emro-app-shell .emro-query-workbench .ui-selectcheckboxmenu .ui-selectcheckboxmenu-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 100%;
}

body.emro-app-shell .emro-query-workbench .ui-selectcheckboxmenu .ui-selectcheckboxmenu-label-container {
    padding: 4px 0.5rem;
    line-height: normal;
}

body.emro-app-shell .emro-query-workbench .ui-selectcheckboxmenu .ui-selectcheckboxmenu-label {
    margin: 0;
    padding: 0;
    font-size: inherit;
    line-height: normal;
}

body.emro-app-shell .emro-query-workbench .ui-inputnumber,
body.emro-app-shell .emro-query-workbench .ui-calendar {
    min-height: 0;
    height: auto !important;
    padding: 0;
    border-width: 0;
}

body.emro-app-shell .emro-query-workbench .ui-calendar {
    display: inline-flex;
    align-items: stretch;
}

body.emro-app-shell .emro-query-workbench .ui-calendar .ui-inputfield {
    min-width: 0;
    flex: 1;
}

body.emro-app-shell .emro-query-workbench .ui-calendar .ui-datepicker-trigger {
    height: auto;
    min-height: var(--emro-control-height);
    padding: 0;
}

body.emro-app-shell .emro-query-workbench .ui-calendar .ui-datepicker-trigger .ui-button-text {
    padding: 0 !important;
}

body.emro-app-shell .emro-query-workbench .emro-query-find.ui-button,
body.emro-app-shell .emro-query-workbench .ui-datatable .emro-query-row-action.ui-button {
    width: auto !important;
    max-width: none !important;
    min-height: var(--emro-control-height);
    height: auto;
    padding: 4px 0 !important;
    box-sizing: border-box;
    border: 1px solid var(--emro-color-action) !important;
    border-radius: 0.375rem;
    color: var(--emro-color-action) !important;
    background: var(--emro-color-surface) !important;
    font-size: 1rem !important;
    font-weight: 700;
    line-height: normal;
    white-space: nowrap;
    box-shadow: none;
}

body.emro-app-shell .emro-query-workbench .emro-query-find.ui-button {
    min-width: 6.5rem;
    color: #fff !important;
    background: var(--emro-color-action) !important;
}

body.emro-app-shell .emro-query-workbench .emro-query-row-action.ui-button {
    min-width: 5.75rem;
}

body.emro-app-shell .emro-query-workbench .emro-query-find.ui-button .ui-button-text,
body.emro-app-shell .emro-query-workbench .emro-query-row-action.ui-button .ui-button-text {
    padding: 0 0.75rem !important;
    color: inherit !important;
    font-size: inherit;
    line-height: normal;
}

body.emro-app-shell .emro-query-workbench .emro-query-find.ui-button .ui-button-text {
    padding-left: 1.75rem !important;
}

body.emro-app-shell .emro-query-workbench .emro-query-find.ui-button .ui-button-icon-left {
    left: 0.5rem !important;
    font-size: 0.875rem;
}

body.emro-app-shell .emro-query-workbench .emro-query-row-action.ui-button .ui-button-icon-left {
    display: none;
}

body.emro-app-shell .emro-query-workbench .emro-query-find.ui-button:not(.ui-state-disabled):hover {
    background: var(--emro-color-action-hover) !important;
    border-color: var(--emro-color-action-hover) !important;
}

body.emro-app-shell .emro-query-workbench .ui-datatable .emro-query-row-action.ui-button:not(.ui-state-disabled):hover {
    background: var(--emro-color-action-soft) !important;
}

body.emro-app-shell .emro-query-workbench .emro-query-more-summary {
    color: var(--emro-color-text-muted);
    font-size: 0.75rem;
}

body.emro-app-shell .emro-query-workbench .emro-query-more-filters.ui-fieldset {
    margin: 0;
    padding: 0.25rem 0.75rem 0.75rem;
    border: 1px solid var(--emro-color-border);
    border-radius: 0.375rem;
    background: var(--emro-color-surface-raised);
}

body.emro-app-shell .emro-query-workbench .emro-query-more-filters.ui-fieldset .ui-fieldset-legend {
    padding: 0.25rem 0.5rem;
    color: var(--emro-color-action);
    font-size: 0.8125rem;
    font-weight: 700;
}

/* Opted-in legacy secondary panels remain in normal flow. The refreshed header
   uses its own flex containers and never reserves space for an overlay toolbar. */
body.emro-app-shell .emro-query-workbench .emro-dw-toolbar {
    height: auto;
    min-height: 0;
    margin: 0 0 0.375rem;
    position: static;
    z-index: auto;
}

body.emro-app-shell .emro-query-workbench .ui-datatable-header {
    min-height: 0;
    padding: 0.5rem 0.75rem !important;
    background: var(--emro-color-surface);
}

body.emro-app-shell .emro-query-workbench .emro-query-results-tools,
body.emro-app-shell .emro-query-workbench .emro-query-results-options {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.625rem;
}

body.emro-app-shell .emro-query-workbench .emro-query-results-tools {
    justify-content: space-between;
}

body.emro-app-shell .emro-query-workbench .emro-query-results-count {
    color: var(--emro-color-text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

body.emro-app-shell .emro-query-workbench .emro-query-results-tools .emro-query-icon-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--emro-control-height);
    height: var(--emro-control-height);
    min-width: var(--emro-control-height);
    min-height: var(--emro-control-height);
    padding: 0 !important;
    box-sizing: border-box;
    border: 1px solid var(--emro-color-border) !important;
    border-radius: 0.375rem;
    color: var(--emro-color-action) !important;
    background: var(--emro-color-surface) !important;
    box-shadow: none;
}

body.emro-app-shell .emro-query-workbench .emro-query-results-tools .emro-query-icon-tool:not(.ui-state-disabled):hover {
    background: var(--emro-color-action-soft) !important;
}

body.emro-app-shell .emro-query-workbench .emro-query-results-tools .emro-query-icon-tool .ui-button-text {
    display: none;
    padding: 0 !important;
}

body.emro-app-shell .emro-query-workbench .emro-query-results-tools .emro-query-icon-tool .ui-button-icon-left {
    position: static;
    margin: 0 !important;
    font-size: 1rem;
}

body.emro-app-shell .emro-query-workbench .emro-query-results-tools .emro-query-icon-tool img {
    width: 1rem;
    height: 1rem;
}

/* Qualify the generated DataTable root to supersede the inherited automatic
   wide-table density; audited query grids retain their requested standard. */
body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table {
    min-width: 0;
    --emro-control-height: 1.625rem;
    font-size: 0.875rem;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table th,
body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table td,
body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table td .ui-outputlabel {
    font-size: 0.875rem !important;
    line-height: 1.4;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table thead th {
    padding: 0.5rem 0.625rem 0.625rem;
    background: var(--emro-color-surface-raised);
    vertical-align: bottom;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table .ui-column-title {
    font-size: 0.8125rem;
    font-weight: 700;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table .ui-column-filter {
    display: block;
    width: 100%;
    margin: 0.375rem 0 0;
    box-sizing: border-box;
}

/* A scrollable table keeps a zero-height clone of its header inside the
   body; cell padding would show it as a clipped strip of header text. */
body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table .ui-datatable-scrollable-theadclone th {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table tbody td {
    padding-block: 0.5rem;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table tbody tr.ui-state-highlight {
    border-color: var(--emro-color-border) !important;
    box-shadow: inset 3px 0 var(--emro-color-action);
    outline: none;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table tbody tr.ui-state-highlight td {
    border-color: var(--emro-color-border) !important;
}

/* MCC urgency rows keep their native red/yellow status backgrounds on focus.
   The inset selection indicator above still identifies the selected record. */
body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table tbody tr.ui-state-highlight:not(.outOfServiceRed):not(.outOfServiceYellow) {
    background: var(--emro-color-action-soft) !important;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table tbody tr.ui-state-highlight:not(.outOfServiceRed):not(.outOfServiceYellow) td {
    background: transparent !important;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table .emro-query-identifier .ui-outputlabel {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table .ui-paginator {
    min-height: 2.5rem;
    padding: 0.375rem 0.75rem;
    justify-content: flex-end;
    gap: 0.25rem;
    background: var(--emro-color-surface);
    font-variant-numeric: tabular-nums;
}

body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table .ui-paginator-current {
    margin-right: auto;
    margin-left: 0;
}

body.emro-app-shell .emro-query-workbench .emro-query-row-details {
    padding: 0.75rem;
    background: var(--emro-color-surface-raised);
    border-left: 3px solid var(--emro-color-border-strong);
}

body.emro-app-shell .emro-query-workbench .ui-button:focus-visible,
body.emro-app-shell .emro-query-workbench a:focus-visible,
body.emro-app-shell .emro-query-workbench .ui-inputfield:focus-visible {
    outline: 2px solid var(--emro-color-action);
    outline-offset: 2px;
}

@media (max-width: 64rem) {
    body.emro-app-shell .emro-query-workbench .emro-query-field-grid,
    body.emro-app-shell .emro-query-workbench .emro-query-primary-fields,
    body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 40rem) {
    body.emro-app-shell .emro-query-heading {
        padding-inline: 0.75rem;
    }
    body.emro-app-shell .emro-query-workbench .emro-query-field-grid,
    body.emro-app-shell .emro-query-workbench .emro-query-primary-fields,
    body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields {
        grid-template-columns: minmax(0, 1fr);
    }
    body.emro-app-shell .emro-query-workbench .emro-query-find.ui-button {
        width: 100% !important;
    }
    body.emro-app-shell .emro-query-workbench .emro-query-results-tools {
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* A sidebar or dialog may narrow the search while the viewport stays wide.
   Reserve room for Find before the four-track minimum could overflow. */
@container emro-primary-search (max-width: 50rem) {
    body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields {
        flex-basis: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container emro-primary-search (max-width: 40rem) {
    body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-full-primary-fields {
        flex-basis: 100%;
        grid-template-columns: minmax(0, 1fr);
    }
    body.emro-app-shell .emro-full-workbench .emro-query-primary .emro-query-find.ui-button {
        width: 100% !important;
    }
}

@media (hover: none) and (pointer: coarse) {
    body.emro-app-shell .emro-query-workbench {
        --emro-control-height: var(--emro-control-height-coarse);
    }
    body.emro-app-shell .emro-query-workbench .ui-datatable.ui-widget.emro-query-results-table {
        --emro-control-height: var(--emro-control-height-coarse);
    }
    body.emro-app-shell .emro-query-workbench .emro-query-results-tools .emro-query-icon-tool {
        min-width: var(--emro-control-height-coarse);
        min-height: var(--emro-control-height-coarse);
    }
}

/* ==========================================================================
   Lookup windows (descriptor "lookup": true). Every rule below is gated on
   .emro-lookup, the frame root that sits next to .emro-query-workbench, or on
   .lookup-dialog, the dialog host, so unflagged windows render exactly as
   before. Tokens only. Rules that must beat a v2 rule above repeat its
   qualifiers, which gives equal specificity and wins by coming later.
   ========================================================================== */

/* The query workbench pins its soft tint to a light-only literal on every
   .emro-query-workbench element, and the results section and the result header
   each carry one inside the frame. Hand lookups the app token back on all of
   them so hover, selected and empty states match the rest of the shell. */
body.emro-app-shell .emro-lookup,
body.emro-app-shell .emro-lookup .emro-query-workbench {
    --emro-color-action-soft: inherit;
}

body.emro-app-shell .emro-lookup {
    color: var(--emro-color-text);
    background: var(--emro-color-surface);
}

/* Criteria band: primary fields in one row with the inline Find. The track
   count follows the available width, so a narrow dialog wraps by itself and
   no container query is needed. More filters sits underneath. */
body.emro-app-shell .emro-lookup .emro-query-search {
    gap: var(--emro-space-2);
    padding: var(--emro-space-3);
    border: thin solid var(--emro-color-border);
    border-radius: var(--emro-radius-md);
    background: var(--emro-color-surface-raised);
}

body.emro-app-shell .emro-lookup .emro-query-primary {
    align-items: end;
    gap: var(--emro-space-3);
}

body.emro-app-shell .emro-lookup .emro-query-primary .emro-full-primary-fields {
    flex: 1 1 calc(var(--emro-space-6) * 10);
    grid-template-columns: repeat(auto-fit, minmax(calc(var(--emro-space-6) * 5), 1fr));
    gap: var(--emro-space-2) var(--emro-space-3);
}

body.emro-app-shell .emro-lookup .emro-query-primary .emro-query-find.ui-button {
    flex: none;
}

body.emro-app-shell .emro-lookup .emro-query-more-filters.ui-fieldset {
    padding: 0 var(--emro-space-3) var(--emro-space-3);
    border-radius: var(--emro-radius-md);
    background: var(--emro-color-surface);
}

body.emro-app-shell .emro-lookup .emro-query-more-filters.ui-fieldset.ui-fieldset-collapsed {
    padding-bottom: var(--emro-space-1);
}

body.emro-app-shell .emro-lookup .emro-query-more-filters.ui-fieldset .ui-fieldset-legend {
    color: var(--emro-color-text);
}

/* Result header: the count, then the strip FullResultTools adds for lookups
   (capped notice, criteria chips, Open or Pick). */
body.emro-app-shell .emro-lookup .emro-query-results-count {
    color: var(--emro-color-text);
    font-size: var(--emro-font-size-md);
    font-weight: 700;
}

/* Let the group that holds the strip take the free width, so Open or Pick
   lands at its end and the icon tools stay at the right edge. */
body.emro-app-shell .emro-lookup .emro-query-results-options:has(> .emro-lookup-strip) {
    flex: 1 1 auto;
    min-width: 0;
}

body.emro-app-shell .emro-lookup .emro-lookup-strip {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--emro-space-2) var(--emro-space-3);
    min-width: 0;
}

/* Body text on the warning tint: the warning colour only carries the border. */
body.emro-app-shell .emro-lookup .emro-lookup-capped {
    padding: var(--emro-space-1) var(--emro-space-2);
    border: thin solid var(--emro-color-warning);
    border-radius: var(--emro-radius-sm);
    color: var(--emro-color-text);
    background: var(--emro-color-warning-soft);
    font-size: var(--emro-font-size-sm);
    font-weight: 600;
}

body.emro-app-shell .emro-lookup .emro-lookup-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--emro-space-1);
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

body.emro-app-shell .emro-lookup .emro-lookup-chip {
    max-width: 100%;
    padding: 0 var(--emro-space-2);
    border: thin solid var(--emro-color-border);
    border-radius: var(--emro-radius-lg);
    color: var(--emro-color-text);
    background: var(--emro-color-surface-muted);
    font-size: var(--emro-font-size-sm);
    line-height: var(--emro-line-height);
    overflow-wrap: anywhere;
}

/* Open or Pick in the header is a plain p:commandButton, not a grid cell
   button, so it owns its colours like Find does. Its label takes the text
   token. */
body.emro-app-shell .emro-lookup .emro-lookup-row-action.ui-button {
    width: auto !important;
    min-width: calc(var(--emro-space-6) * 3);
    min-height: var(--emro-control-height);
    margin-inline-start: auto;
    box-sizing: border-box;
    border: thin solid var(--emro-color-action) !important;
    border-radius: var(--emro-radius-md);
    color: var(--emro-color-text) !important;
    background: var(--emro-color-surface) !important;
    font-size: var(--emro-font-size-lg) !important;
    font-weight: 700;
    line-height: normal;
    white-space: nowrap;
    box-shadow: none;
}

body.emro-app-shell .emro-lookup .emro-lookup-row-action.ui-button .ui-button-text {
    padding-inline: var(--emro-space-3) !important;
    color: inherit !important;
}

body.emro-app-shell .emro-lookup .emro-lookup-row-action.ui-button:not(.ui-state-disabled):hover {
    background: var(--emro-color-action-soft) !important;
}

body.emro-app-shell .emro-lookup .emro-lookup-row-action.ui-button:focus-visible {
    outline: calc(var(--emro-space-1) / 2) solid var(--emro-color-action);
    outline-offset: calc(var(--emro-space-1) / 2);
}

/* Rows. Double-click and Enter open or pick, so the rows read as clickable;
   hover and selected stay separable (the selected token is the deeper one). */
body.emro-app-shell .emro-lookup .ui-datatable.ui-widget.emro-query-results-table tbody tr.ui-datatable-selectable {
    cursor: pointer;
}

body.emro-app-shell .emro-lookup .ui-datatable.ui-widget.emro-query-results-table tbody tr.ui-datatable-selectable:not(.ui-state-highlight):not(.outOfServiceRed):not(.outOfServiceYellow):hover,
body.emro-app-shell .emro-lookup .ui-datatable.ui-widget.emro-query-results-table tbody tr.ui-datatable-selectable:not(.ui-state-highlight):not(.outOfServiceRed):not(.outOfServiceYellow).ui-state-hover {
    color: var(--emro-color-text);
    background: var(--emro-color-action-soft);
}

body.emro-app-shell .emro-lookup .ui-datatable.ui-widget.emro-query-results-table tbody tr.ui-state-highlight:not(.outOfServiceRed):not(.outOfServiceYellow) {
    color: var(--emro-color-text);
    background: var(--emro-color-selected) !important;
}

/* PrimeFaces removes the tbody outline, which leaves Enter-to-open on the
   selected row with no visible keyboard focus. */
body.emro-app-shell .emro-lookup .ui-datatable.ui-widget.emro-query-results-table tbody.ui-datatable-data:focus-visible tr.ui-state-highlight {
    outline: calc(var(--emro-space-1) / 2) solid var(--emro-color-action);
    outline-offset: calc(var(--emro-space-1) / -2);
}

/* No records: the grid's own empty row, as a panel. */
body.emro-app-shell .emro-lookup .ui-datatable.ui-widget.emro-query-results-table .ui-datatable-empty-message td {
    padding: var(--emro-space-6) var(--emro-space-4);
    border: thin dashed var(--emro-color-border);
    color: var(--emro-color-text-muted);
    background: var(--emro-color-surface-raised);
    text-align: center;
}

/* Per-row action buttons. Cell buttons carry inline important colours, so
   only border, radius and the hover and focus ring are set here. Buttons that
   already wear .emro-query-row-action keep the v2 border and padding. */
body.emro-app-shell .emro-lookup .ui-datatable tbody td .emro-native-dw-cell-action .ui-button:not(.emro-query-row-action) {
    border: thin solid var(--emro-color-border-strong);
    border-radius: var(--emro-radius-sm);
}

body.emro-app-shell .emro-lookup .ui-datatable tbody td .emro-native-dw-cell-action .ui-button:not(.ui-state-disabled):hover,
body.emro-app-shell .emro-lookup .ui-datatable tbody td .emro-query-row-action.ui-button:not(.ui-state-disabled):hover {
    border-color: var(--emro-color-action);
    box-shadow: 0 0 0 calc(var(--emro-space-1) / 2) var(--emro-color-selected);
}

body.emro-app-shell .emro-lookup .ui-datatable tbody td .emro-native-dw-cell-action .ui-button:focus-visible,
body.emro-app-shell .emro-lookup .ui-datatable tbody td .emro-query-row-action.ui-button:focus-visible {
    outline: calc(var(--emro-space-1) / 2) solid var(--emro-color-action);
    outline-offset: calc(var(--emro-space-1) / 2);
}

/* Pick dialogs: the host p:dialog's width attribute sizes them, so PrimeFaces
   sets the width inline and resizing can shrink or grow it. Here they are only
   capped to the viewport height and scroll inside it. The theme gives every
   dialog overflow hidden through body.emro-app-shell .ui-dialog, and the
   inline overflow auto the other dialogs carry is dropped for lookups, so the
   third class is what lets this win. .lookup-escape is the script's hook for
   Esc and has no rules of its own. */
.lookup-dialog.ui-dialog.ui-widget {
    max-height: 95vh;
    overflow: auto;
}

/* The dialog is resizable. PrimeFaces parks its resize handles 5px outside the
   box: under overflow auto the bottom and right ones make the dialog scroll by
   exactly that much, and the top and left ones are clipped to a sliver. */
.lookup-dialog.ui-dialog .ui-resizable-n,
.lookup-dialog.ui-dialog .ui-resizable-ne,
.lookup-dialog.ui-dialog .ui-resizable-nw {
    top: 0;
}

.lookup-dialog.ui-dialog .ui-resizable-s,
.lookup-dialog.ui-dialog .ui-resizable-se,
.lookup-dialog.ui-dialog .ui-resizable-sw {
    bottom: 0;
}

.lookup-dialog.ui-dialog .ui-resizable-e,
.lookup-dialog.ui-dialog .ui-resizable-ne,
.lookup-dialog.ui-dialog .ui-resizable-se {
    right: 0;
}

.lookup-dialog.ui-dialog .ui-resizable-w,
.lookup-dialog.ui-dialog .ui-resizable-nw,
.lookup-dialog.ui-dialog .ui-resizable-sw {
    left: 0;
}
