body, body .ui-widget, body .ui-inputfield, body select {
    font-size: 12px;
}

body .ui-datatable .ui-reflow-hide {
    display: none !important;
}

body .ui-datatable .ui-reflow-show {
    display: block;
}

body .ui-datatable-reflow .ui-datatable-header {
    background: none;
}

body .ui-datatable-reflow .ui-datatable-data td[role="gridcell"]:not(.ui-helper-hidden) {
    display: flex;
}

body .ui-datatable-reflow .ui-datatable-data .ui-sortable-placeholder td {
    border: 0;
    padding: .5em;
}

body .ui-datatable-reflow.ui-sortable-helper,
body .ui-datatable-reflow.ui-sortable-helper td {
    max-width: 90vw;
}

body .ui-datatable-reflow.ui-sortable-helper tr {
    border-top: 1px solid rgba(0, 0, 0, .08);
}

body .ui-datatable-reflow .ui-datatable-data td[role="gridcell"] .ui-column-title {
    font-weight: bold;
}

body .ui-datatable-reflow .ui-datatable-data td[role="gridcell"].actions,
body .ui-datatable-reflow tfoot td.actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: .5em;
    box-sizing: border-box;
    min-width: 100%;
}

body .ui-datatable-reflow .ui-datatable-data td[role="gridcell"].actions .ui-column-title {
    display: none;
}

body .ui-datatable-reflow .ui-datatable-data td[role="gridcell"].actions .ui-button,
body .ui-datatable-reflow tfoot td.actions .ui-button {
    flex: 1;
    width: auto;
    margin: 0;
}

body .ui-paginator .ui-paginator-current {
    display: block;
}

body .ui-datatable-reflow .ui-reflow-label,
body .ui-datatable-reflow .ui-reflow-dropdown {
    margin: .5em 0 .5em .5em;
}

body .ui-dialog {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 0;
    background: white;
}

body .ui-dialog .ui-dialog-content {
    min-width: auto;
    min-height: calc(100% - 6.5em);
}

/* ── Existing table overrides ─────────────────────────────────────────────── */

body .ui-datatable#table .ui-datatable-data td.actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: auto;
    gap: 0.5em;
}

body .ui-datatable#table .ui-datatable-data td.actions .ui-button {
    width: 100%;
    margin: 0;
}

body .ui-datatable#table .ui-datatable-data td {
    white-space: normal !important;
    word-wrap: break-word;
}

body .ui-datatable#table .ui-datatable-data td.description,
body .ui-datatable#table .ui-datatable-data td.notes {
    max-width: none;
}

/* ── Field-use: compact data tables, large action buttons ─────────────────── */

/*
 * Data cells: tighter padding so more rows fit on screen.
 * The goal is ~6-8 rows visible without scrolling on a phone.
 */
body .ui-datatable .ui-datatable-data > tr > td {
    padding: .3rem .4rem;
    font-size: 0.85em;
    line-height: 1.3;
}

body .ui-datatable thead th {
    padding: .3rem .4rem;
    font-size: 0.8em;
}

body .ui-datatable .ui-datatable-header {
    padding: .4rem .5rem;
}

body .ui-paginator {
    padding: .3rem;
    font-size: 0.85em;
}

/*
 * Action buttons: minimum 44px tall per Apple/Google touch guidelines.
 * Wide enough to tap with gloved fingers.
 */
body .ui-datatable td.actions .ui-button,
body .ui-datatable tfoot td .ui-button {
    min-height: 44px;
    min-width: 80px;
    font-size: 0.9em;
    padding: 0 .75em;
    margin: 2px 0;
    touch-action: manipulation; /* prevents 300ms tap delay */
}

/*
 * Status transition buttons on work order detail —
 * extra large since these are the primary field actions.
 */
body .wo-status-btn {
    min-height: 52px;
    min-width: 110px;
    font-size: 1em;
    font-weight: bold;
    touch-action: manipulation;
}

/*
 * Work order cards on the index dashboard —
 * full-width card layout, generous tap target for Open button.
 */
body .mobile-wo-table .ui-datatable-data > tr > td {
    padding: .6rem .5rem;
    font-size: 0.9em;
}

body .mobile-wo-table .ui-button {
    min-height: 48px;
    width: 100%;
    font-size: 1em;
    font-weight: 600;
    touch-action: manipulation;
}

/*
 * Quick nav grid buttons on index page —
 * square-ish, easy to tap.
 */
body .quick-nav-grid .ui-button {
    min-height: 52px;
    width: 100%;
    font-size: 0.9em;
    touch-action: manipulation;
}

/*
 * Panel headers — slightly more compact.
 */
body .ui-panel .ui-panel-titlebar {
    padding: .4rem .75rem;
    font-size: 0.9em;
}

body .ui-panel .ui-panel-content {
    padding: .4rem .5rem;
}

/*
 * Fieldset labels/inputs in dialogs — keep full size for usability
 * when filling in work order data in the field.
 */
body .ui-dialog .ui-fieldset .ui-outputlabel {
    font-size: 0.9em;
    margin: .6em 0 .3em;
}

body .ui-dialog .ui-inputfield,
body .ui-dialog .ui-selectonemenu {
    min-height: 44px;
    font-size: 1em;
}

body .ui-dialog .ui-inputnumber-input {
    min-height: 44px;
}

/*
 * Save/Cancel buttons in dialogs — large for field use.
 */
body .ui-dialog footer .ui-button {
    min-height: 48px;
    min-width: 90px;
    font-size: 1em;
    touch-action: manipulation;
}
