/* Shared admin interaction layer. No print/PDF, auth redesign or business styling.
   Keep widths/visibility and widget layout under their existing owners. */
html body :is(#wrapper,.modal,.swal2-container) :is(a,button,input,select,textarea,[tabindex]):focus-visible {
    outline:3px solid var(--app-focus-color,#005a85)!important;
    outline-offset:3px;
    box-shadow:0 0 0 2px #fff!important;
}
html body :is(#wrapper,.modal,.swal2-container) :is(
    input:not(:where([type=checkbox],[type=radio],[type=file],[type=range],[type=color],[type=image],[type=button],[type=submit],[type=reset])),
    select,textarea,.select2-selection
):focus-visible {
    outline-width:1px!important;
    outline-offset:-1px;
    box-shadow:none!important;
}
html body :is(#wrapper,.modal) :is(input,select,textarea,button,a,[tabindex]) {
    scroll-margin-block:72px 24px;
}
html body :is(.content-wrapper,.modal-body) .help-block:not(:is(.text-danger,.text-success,.text-warning)) {color:#526575}
html body :is(.content-wrapper,.modal-body) .form-control::placeholder {color:#657586;opacity:1}
[data-app-scroll-accessible] {overscroll-behavior-x:contain}

@media screen and (max-width:991px) {
    :root {--app-action-target:44px;--app-touch-target:44px}
    html body :is(#wrapper,.modal) .form-control:not(:is(.app-binary-native,.select2-hidden-accessible,[type=hidden],[type=checkbox],[type=radio],[type=file])) {
        min-height:44px!important;
        font-size:16px!important;
        line-height:1.4;
    }
    html body :is(#wrapper,.modal) textarea.form-control {height:auto;min-height:96px!important}
    html body :is(#wrapper,.modal) :is(.select2-selection--single,.select2-selection--multiple) {min-height:44px!important}
    html body :is(#wrapper,.modal) .select2-selection--single {height:44px!important}
    html body :is(#wrapper,.modal) .select2-selection--single :is(.select2-selection__rendered,.select2-selection__arrow) {line-height:42px;height:42px}
    html body .select2-container .select2-results__option {min-height:44px;padding:10px 12px;font-size:16px}
    html body .select2-container .select2-search__field {font-size:16px!important;min-height:32px}
    html body :is(#wrapper,.modal) .app-binary-control {min-width:min(180px,100%);width:180px;max-width:100%}
    html body :is(#wrapper,.modal) .app-binary-control>.app-binary-option,
    html body :is(#wrapper,.modal) .btn-group.app-binary-options>:is(label,span.ef24-form-caption).btn {
        min-height:44px!important;height:44px!important;min-width:64px!important;font-size:14px!important;
    }
    html body :is(#wrapper,.modal) .btn:not(:where(.jodit-container *,.fc *,.datepicker *,.bootstrap-datetimepicker-widget *,.bootstrap-colorpicker *)) {min-height:44px}
    html body :is(#wrapper,.modal) :is(.app-detail-step,.view-filter-reset) {width:44px!important;min-width:44px!important;height:44px!important;min-height:44px!important}
    html body :is(#wrapper,.modal) .app-detail-quantity input[name=cantidades] {height:44px!important}
    html body :is(#wrapper,.modal) .app-detail-table>tbody>tr>td[data-detail-column=percent]:has(>input[name=descuento])::after {height:44px}
    html body :is(#wrapper,.modal) .app-detail-search.input-group>.input-group-btn>.btn {width:44px!important;min-width:44px!important;max-width:44px!important;height:44px!important;min-height:44px!important;max-height:44px!important}
    html body :is(#wrapper,.modal) [data-table-action-slot]:is(a,button) {min-width:44px;min-height:44px}
    html body :is(#wrapper,.modal) :is(.dataTables_filter,.dataTables_length) :is(input,select) {min-height:44px;font-size:16px!important}
    html body :is(#wrapper,.modal) :is(.pagination a,.pagination span,.paginate_button) {min-width:44px;min-height:44px;box-sizing:border-box}
    html body :is(#wrapper,.modal) :is(.modal-header .close,.swal2-close) {min-width:44px;min-height:44px}
    html body :is(#wrapper,.modal) :is(.help-block,.field-validation-message,.app-field-error) {font-size:13px;line-height:1.5}
    html body #wrapper .sidebar-menu li>a {min-height:44px}
    html body #wrapper .sidebar-menu .treeview-menu li>a {padding-top:10px;padding-bottom:10px}
}
@container (max-width:460px) {
    html body .client-form-layout .client-form-toggle {display:block}
    html body .client-form-layout .client-form-toggle>.control-label {max-width:none;margin-bottom:6px}
    html body .client-form-layout .client-form-toggle>.form-group {width:180px;max-width:100%}
}
@media (forced-colors:active) {
    html body :is(#wrapper,.modal,.swal2-container) :is(a,button,input,select,textarea,[tabindex]):focus-visible {outline-color:Highlight!important;box-shadow:none!important}
}
@media print {
    html body :is(#wrapper,.modal) [data-app-scroll-accessible] {outline:0!important;box-shadow:none!important;overscroll-behavior:auto}
}

/* Data controls remain outside the horizontal scroller. Applies only to admin lists;
   calendars, editors, editable detail cards, PDF and mail keep their own layout. */
.content-wrapper .app-page-table-container {min-width:0;max-width:100%}
.content-wrapper .app-page-table-wrapper {min-width:0;max-width:100%}
.content-wrapper .app-page-table-scroll {width:100%;min-width:0;max-width:100%;clear:both;margin:0;border:0;overflow-x:auto;overscroll-behavior-x:contain}
@media screen and (min-width:992px) { .content-wrapper .app-page-table-container .app-page-table-scroll {display:contents} }
@media screen and (max-width:991px) {
    .content-wrapper :is(.app-page-table-container,.app-page-table-wrapper) {overflow:visible!important}
    .content-wrapper .app-page-table-scroll[data-app-scroll-accessible]::before,
    .content-wrapper .app-page-native-scroll:has(.dataTables_scrollBody[data-app-scroll-accessible])::before {
        content:'\2194 Desliza la tabla para ver todas las columnas';display:block;position:sticky;left:0;width:100%;
        box-sizing:border-box;padding:8px 2px;color:#526575;font-size:12px;line-height:1.5;white-space:normal;
    }
    .content-wrapper .app-page-table-wrapper :is(.dataTables_filter,.dataTables_length,.dataTables_info) {
        float:none!important;max-width:100%;white-space:normal;text-align:left;
    }
    .content-wrapper .app-page-table-wrapper .dataTables_filter label {
        display:flex;flex-wrap:wrap;align-items:center;gap:8px;max-width:100%;
    }
    .content-wrapper .app-page-table-wrapper .dataTables_filter input {
        flex:1 1 150px;width:auto!important;min-width:0;max-width:100%;margin-left:0;box-sizing:border-box;
    }
    .content-wrapper .app-page-table-wrapper .dt-buttons {
        display:flex;flex-wrap:wrap;align-items:center;float:none;gap:6px;max-width:100%;margin-bottom:10px;
    }
    .content-wrapper .app-page-table-wrapper .dataTables_paginate {
        display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:4px;
        float:none!important;max-width:100%;white-space:normal!important;text-align:center;
    }
    .content-wrapper .app-page-table-wrapper .dataTables_paginate>span,
    .content-wrapper .app-page-table-wrapper .dataTables_paginate .pagination {
        display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:4px;max-width:100%;margin:0;padding:0;
    }
    .content-wrapper .app-page-table-wrapper .dataTables_paginate .paginate_button {margin:0;box-sizing:border-box}
}
@media screen and (max-width:767px) {
    /* Legacy tabbed forms nest four Bootstrap padding layers. Keep the gutters
       once on phones, so fields use the available width instead of a thin strip. */
    .content-wrapper .panel-body:has(>.col-md-12>.nav-tabs-custom) {padding:12px!important}
    .content-wrapper .panel-body>.col-md-12:has(>.nav-tabs-custom) {padding-left:0!important;padding-right:0!important}
    .content-wrapper .nav-tabs-custom>.tab-content {padding:12px 8px}
    .content-wrapper .nav-tabs-custom>.tab-content>.tab-pane>.box-body {padding-left:0;padding-right:0}
    .content-wrapper .nav-tabs-custom>.tab-content>.tab-pane>.box-body>.form-group[class*=col-] {padding-left:6px!important;padding-right:6px!important}
    html body :is(#wrapper,.modal) .app-detail-search.input-group>.input-group-btn,
    html body :is(#wrapper,.modal) .account-payment-lookup>.input-group-btn {
        flex:0 0 44px;width:44px!important;min-width:44px;max-width:44px;
    }
    .content-wrapper .nav-tabs:not(.nav-stacked) {
        display:flex;flex-wrap:nowrap;max-width:100%;overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;
    }
    .content-wrapper .nav-tabs:not(.nav-stacked)>li {float:none;flex:0 0 auto}
    .content-wrapper .nav-tabs:not(.nav-stacked)>li>a {min-height:44px;white-space:nowrap}
}
@media screen and (max-width:575px) {
    /* Debit-note detail fields shared by create/edit: a two-option tax switch
       needs its own row when a Bootstrap half-column is narrower than a thumb. */
    .content-wrapper .box-body:has(> .form-group #valormod):has(> .form-group #iva_type)>.form-group:has(#valormod,#iva_type) {width:100%;float:none}
    .content-wrapper .input-group:has(>#iva_type) {display:block;width:100%;max-width:100%}
    .content-wrapper .app-page-table-wrapper .dataTables_paginate>span>.paginate_button:not(.current),
    .content-wrapper .app-page-table-wrapper .dataTables_paginate>span>.ellipsis,
    .content-wrapper .app-page-table-wrapper .dataTables_paginate>.paginate_button:is(.first,.last),
    .content-wrapper .app-page-table-wrapper .dataTables_paginate .pagination>li:not(.previous):not(.next):not(.active) {display:none!important}
}
@media print {
    .content-wrapper .app-page-table-scroll {overflow:visible;max-width:none}
}

/* Phone hit areas belong to the existing control, never a proxy or overlay.
   Keep desktop geometry, native events and the fixed 54px shell untouched. */
@media screen and (max-width:991px) {
    html[data-eblock-navigation] #wrapper>.main-header .sidebar-toggle {flex-basis:44px;min-width:44px}
    html[data-eblock-navigation] #wrapper>.main-header .navbar-custom-menu>.navbar-nav>li>:is(a,button),
    html[data-eblock-navigation] #wrapper>.main-header .sri-health__toggle {
        display:flex;align-items:center;justify-content:center;min-width:44px;width:44px!important;min-height:44px;height:44px!important;padding:0!important;
    }
    html[data-eblock-navigation] #wrapper>.main-header .sri-health__toggle {width:auto!important;padding:0 12px!important}
    html[data-eblock-navigation] #wrapper>.main-header .navbar-custom-menu {overscroll-behavior-x:contain}
    html body #wrapper .main-header :is(input[type=search],input[type=text]) {min-height:44px;font-size:16px}
    html body #wrapper .main-header :is(.app-company-recent-tools button,.user-menu-roles>summary) {min-height:44px}
    html[data-eblock-navigation] body #wrapper>.main-header .app-notification-center .app-notification-refresh {min-width:44px;min-height:44px;width:44px;height:44px}
    html body #wrapper .main-sidebar .ef24-sidebar-search__clear {width:44px;height:44px;min-width:44px;min-height:44px}
    html body #wrapper .main-sidebar #menuSearch {padding-right:54px!important}
    html body #wrapper .main-header .app-shell-swatches button {flex-basis:44px;width:44px;height:44px;min-width:44px;min-height:44px}
    html body #wrapper .main-header :is(.dropdown-menu li>a,.user-menu-profile,.user-menu-logout) {min-height:44px;display:flex;align-items:center}

    .content-wrapper .box-header:has(>.box-tools) {display:flex;flex-wrap:wrap;align-items:center;gap:6px}
    .content-wrapper .box-header:has(>.box-tools)::before,
    .content-wrapper .box-header:has(>.box-tools)::after {display:none}
    .content-wrapper .box-header:has(>.box-tools)>.box-title {flex:1 1 130px;min-width:0;line-height:1.4}
    .content-wrapper .box-header>.box-tools {position:static;display:flex;align-items:center;flex:0 0 auto;gap:2px;margin-left:auto;float:none!important}
    html body #wrapper .content-wrapper .btn-box-tool {display:inline-flex;align-items:center;justify-content:center;min-width:44px;width:44px;min-height:44px;padding:0;font-size:16px;line-height:1}
    html body #wrapper .management-summary__detail-trigger {min-height:44px}
    html body #wrapper .profile-page .profile-page__save {flex-basis:44px;min-width:44px;width:44px;min-height:44px;height:44px}
    html body #wrapper #company-directory-search {min-height:44px;font-size:16px}

    html body :is(#wrapper,.modal) table.app-system-table [data-table-action]:is(a,button,span):not([hidden]),
    html body :is(#wrapper,.modal) .sri-state-link:not([hidden]),
    html body :is(#wrapper,.modal) .dt-button:not([hidden]) {
        display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;min-width:44px;min-height:44px;vertical-align:middle;
    }
    html body :is(#wrapper,.modal) table.app-system-table :is(img,i)[data-table-action],
    html body #wrapper .content :is(img.file,img.acction)[onclick] {
        display:inline-block;box-sizing:border-box;width:44px!important;height:44px!important;min-width:44px;min-height:44px;padding:8px;object-fit:contain;vertical-align:middle;
    }
    html body #wrapper .content a:has(>img.file) {display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;vertical-align:middle}
    html body :is(#wrapper,.modal) table.app-system-table>tbody>tr>td>a:not([hidden]),
    html body #wrapper .content :is(.alert,.box-widget)>a:not([hidden]) {display:inline-flex;align-items:center;min-width:44px;min-height:44px;vertical-align:middle}
    html body :is(#wrapper,.modal) table.app-system-table :is(input[type=number],input[type=text],select):not(.app-binary-native) {min-height:44px;font-size:16px}
    html body :is(#wrapper,.modal) .dropdown-menu>li>a {min-height:44px;white-space:normal}
    html body :is(#wrapper,.modal) .form-check:has(>.form-check-input) {display:flex;align-items:center;flex-wrap:wrap;gap:8px}
    html body :is(#wrapper,.modal) .form-check>input.ef24-selection-check[type=checkbox] {margin:0;flex:0 0 44px}
    html body :is(#wrapper,.modal) .form-check>.form-check-label {display:inline-flex;align-items:center;min-height:44px;margin:0;cursor:pointer}
    html body :is(#wrapper,.modal) .notice-reader-preference {min-height:44px}
    html body :is(#wrapper,.modal,.app-upload-viewer) .app-upload-button {min-width:44px;min-height:44px}
    html body :is(#wrapper,.modal) .dropzone .dz-preview .dz-remove {width:44px!important;min-width:44px!important;height:44px!important;min-height:44px!important}
    html body :is(.app-dialog,.swal2-popup) button {min-width:44px;min-height:44px}
    html body .swal2-popup :is(input,select,textarea):not([type=hidden]):not([type=checkbox]):not([type=radio]) {min-height:44px;font-size:16px}
    html body :is(#wrapper,.modal) .select2-selection--multiple .select2-selection__choice {display:inline-flex;align-items:center;max-width:100%;min-height:44px;white-space:normal;overflow-wrap:anywhere}
    html body :is(#wrapper,.modal) .select2-selection--multiple .select2-selection__choice__remove {display:inline-flex;align-items:center;justify-content:center;flex:0 0 44px;min-width:44px;min-height:44px;margin:0 4px 0 0;font-size:20px}

    html body #medical-appointments .fc .fc-toolbar button {min-width:44px!important;min-height:44px;height:auto}
    html body #medical-appointments .appointment-patient-lookup .btn {flex-basis:44px!important;width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important}
    #medical-appointments .fc .fc-event {min-height:32px;box-sizing:border-box;padding:6px 3px}
    html body #toast-container>div {padding-right:54px}
    html body #toast-container .toast-close-button {position:absolute;right:0;top:0;width:44px;height:44px;min-width:44px;min-height:44px;display:flex;align-items:center;justify-content:center}

    /* Native checkbox remains the 44px target; paint its familiar mark inside it. */
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox] {position:relative;width:44px;height:44px;min-width:44px;margin:0 auto;padding:0;border:0!important;background:transparent!important;box-shadow:none!important}
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]::before {content:'';position:absolute;inset:9px;border:2px solid #afc2d2;border-radius:5px;background:#fff;box-sizing:border-box;pointer-events:none}
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]:checked::before,
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]:indeterminate::before {background:#1489bc;border-color:#1489bc}
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]:checked::after {content:'';position:absolute;left:18px;top:14px;width:8px;height:13px;border:solid #fff;border-width:0 3px 3px 0;transform:rotate(45deg);pointer-events:none;box-sizing:border-box}
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]:indeterminate::after {content:'';position:absolute;inset:20px 16px;background:#fff;transform:none;width:auto;height:auto;border:0;pointer-events:none}
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]:disabled::before {background:#edf1f5;border-color:#c5cfd9}
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]:disabled:checked::before {background:#94a5b5;border-color:#94a5b5}
}
@media screen and (max-width:991px) and (forced-colors:active) {
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox] {-webkit-appearance:auto;appearance:auto}
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]::before,
    html body :is(#wrapper,.modal) input.ef24-selection-check[type=checkbox]::after {display:none}
}
