/* These controls have no layout effect outside the mobile breakpoint. */
.pwa-mobile-title, .pwa-mobile-backdrop, .pwa-mobile-chat-back { display: none; }
@media (max-width: 767px), (max-width: 1023px) and (pointer: coarse) {
    html, body { width: 100%; height: 100%; overflow: hidden !important; overscroll-behavior: none; }
    body { --pwa-header-height: calc(52px + env(safe-area-inset-top, 0px)); }
    body .wrapper { min-height: 0 !important; height: var(--pwa-viewport-height, 100dvh); overflow: hidden !important; }
    body .main-header, body .main-header.hidden1 {
        position: fixed !important; top: 0; left: 0; right: 0; margin: 0 !important;
        height: var(--pwa-header-height); padding-top: env(safe-area-inset-top, 0px); z-index: 1030;
        background: #008d4c; transition: none;
    }
    body .main-header .navbar { margin: 0 !important; min-height: 52px; display: flex; align-items: center; }
    body .main-header .sidebar-toggle, body .main-header.hidden1 .sidebar-toggle {
        position: static !important; display: flex; align-items: center; justify-content: center;
        width: 52px; height: 52px; margin: 0 !important; padding: 0 !important; flex: 0 0 52px;
    }
    body .main-header .sidebar-toggle:before { font-size: 20px; }
    .pwa-mobile-title { display: flex; flex-direction: column; justify-content: center; flex: 1; min-width: 0; color: white; padding-right: 12px; line-height: 1.25; }
    .pwa-mobile-brand { font-size: 15px; font-weight: 600; white-space: nowrap; }
    .pwa-mobile-version { font-size: 12px; font-weight: 400; margin-left: 4px; }
    .pwa-mobile-page { font-size: 12px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    body .navbar-custom-menu { margin-left: auto; flex-shrink: 0; }
    body .main-header ~ .content-wrapper, body .main-header.hidden1 ~ .content-wrapper {
        position: relative; margin: var(--pwa-header-height) 0 0 !important; width: 100% !important;
        height: calc(var(--pwa-viewport-height, 100dvh) - var(--pwa-header-height)) !important;
        min-height: 0 !important; overflow: auto !important; transform: none !important;
        padding-bottom: env(safe-area-inset-bottom, 0px); -webkit-overflow-scrolling: touch;
    }
    body .main-sidebar, body.sidebar-mini.sidebar-collapse .main-sidebar {
        position: fixed !important; top: var(--pwa-header-height); bottom: 0; left: 0;
        width: min(86vw, 320px) !important; padding-top: 0 !important; margin-top: 0 !important;
        height: calc(var(--pwa-viewport-height, 100dvh) - var(--pwa-header-height));
        min-height: 0 !important; overflow-y: auto; overscroll-behavior: contain;
        transform: translateX(-101%) !important; transition: transform .18s ease; z-index: 1040;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    body.pwa-menu-open .main-sidebar { transform: translateX(0) !important; box-shadow: 8px 0 28px #0004; }
    body .main-sidebar .sidebar { padding-bottom: 16px; }
    body .main-sidebar ul.sidebar-menu { max-height: none; overflow: visible !important; }
    body .main-sidebar .user-panel { min-height: 65px; padding: 12px; }
    body .main-sidebar .user-panel > .info, body.sidebar-mini.sidebar-collapse .sidebar-menu > li > a > span,
    body.sidebar-mini.sidebar-collapse .sidebar-menu > li.header {
        display: block !important; position: static !important; width: auto !important; margin: 0 !important;
    }
    body.sidebar-mini.sidebar-collapse .main-sidebar .user-panel > .info { display: block !important; position: absolute !important; }
    body .main-sidebar .sidebar-menu > li > a { min-height: 48px; padding: 14px 16px; white-space: normal; display: flex; align-items: center; gap: 10px; }
    body .main-sidebar .sidebar-menu .treeview-menu > li > a { min-height: 44px; padding: 12px 16px; white-space: normal; }
    body.sidebar-mini.sidebar-collapse .sidebar-menu > li > .treeview-menu { position: static !important; width: auto !important; margin: 0 !important; }
    body .main-sidebar .sidebar-menu > li > a > .pull-right-container { margin-left: auto !important; order: 2; }
    body.pwa-menu-open .pwa-mobile-backdrop { display: block; position: fixed; inset: var(--pwa-header-height) 0 0; border: 0; background: #0007; z-index: 1035; }
    body .content-wrapper .page_block[hidden="1"] { display: none !important; }
    body .content-wrapper .page_block { width: 100%; min-width: 0; max-width: 100%; }
    body section.content-header { padding: 10px !important; height: auto !important; white-space: normal !important; }
    body section.content-header > div { max-width: 100%; white-space: normal; }
    body .content-header .ui.button { margin: 0 !important; }
    body .content-header > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
    body .content-header .ui.button { height: 44px; flex-shrink: 0; border-radius: 6px; }
    body .content-header .ui.form { margin: 0; }
    body .content-header .ui.input > input { height: 44px; padding: 10px; }
    body .content-header .ui.selection.dropdown { min-height: 44px; display: inline-flex; align-items: center; padding-top: 10px; padding-bottom: 10px; }
    body .content-header .ui.form select { width: auto !important; padding: 8px; }
    body section.content { min-width: 0; padding: 0 8px 8px; }
    body .ui.button, body .btn, body .ui.dropdown > .menu > .item { min-height: 44px; }
    body .ui.button, body .btn { box-sizing: border-box; padding: 12px 14px; font-size: 14px; touch-action: manipulation; }
    body .ui.button:not(.labeled):not(.animated) { display: inline-flex; align-items: center; justify-content: center; gap: 7px; line-height: 20px; vertical-align: middle; }
    body .ui.button:not(.labeled):not(.animated) > i.icon { display: inline-block; flex: 0 0 auto; width: 1.18em; height: 1em; line-height: 1; margin: 0 !important; }
    body table .ui.button, body .ag-cell .ui.button { min-height: 36px; height: 36px; padding: 8px !important; margin-top: 2px; margin-bottom: 2px; }
    body table .ui.icon.button, body .ag-cell .ui.icon.button { min-width: 36px; }
    body .ag-cell .ui.button { vertical-align: top; }
    body .ui.dropdown.button > .menu > .item { display: flex; align-items: center; gap: 10px; padding: 12px !important; font-size: 14px; line-height: 20px; }
    body .ui.dropdown.button > .menu > .item > i.icon { display: inline-block; flex: 0 0 18px; width: 18px; height: 18px; line-height: 18px; margin: 0 !important; }
    body .content-header .ui.dropdown > .menu.pwa-toolbar-menu {
        position: fixed !important; left: var(--pwa-menu-left) !important; top: var(--pwa-menu-top) !important;
        right: auto !important; bottom: auto !important; width: var(--pwa-menu-width); min-width: 0 !important;
        max-height: var(--pwa-menu-height); overflow-y: auto; margin: 0 !important; transform: none !important;
        border-radius: 8px; z-index: 1050;
    }
    body .ui.icon.button { min-width: 44px; }
    body .ui.form input:not([type=checkbox]):not([type=radio]), body .ui.form select,
    body .ui.form textarea, body .form-control, body .ui.search.dropdown > input.search {
        font-size: 16px !important; min-height: 44px; max-width: 100%;
    }
    body .ui.form .fields { display: flex !important; flex-wrap: wrap !important; margin: 0 !important; gap: 10px; }
    body .ui.form .fields > .field, body .ui.form .fields > .fields {
        width: 100% !important; min-width: 0 !important; flex: 1 1 100% !important; padding: 0 !important; margin: 0 0 6px !important;
    }
    body .ui.form .field > label { text-align: left !important; font-size: 14px; line-height: 1.45; }
    body .ui.form .ui.input, body .ui.form .ui.dropdown { min-width: 0 !important; max-width: 100%; }
    body .ui.form .ui.input > input { min-width: 0 !important; width: 100%; }
    body .ui.form .ui.label { white-space: normal; overflow-wrap: anywhere; }
    body .ui.checkbox label { min-height: 32px; padding-top: 3px; }
    body .ui.dropdown .menu { max-width: calc(100vw - 24px); }
    body .ui.dropdown .menu > .item { white-space: normal; }
    body .ui.dimmer.modals { z-index: 2000 !important; padding: 0 !important; overflow: hidden !important; }
    body .ui.dimmer.modals .ui.modal.visible.active, body .ui.dimmer.modals .ui.modal.animating {
        position: fixed !important; top: var(--pwa-viewport-top, 0px) !important; left: 0 !important;
        width: 100% !important; max-width: 100% !important; min-width: 0 !important;
        height: var(--pwa-viewport-height, 100dvh) !important; max-height: var(--pwa-viewport-height, 100dvh) !important;
        margin: 0 !important; padding: 0 !important; transform: none !important; border-radius: 0 !important;
        display: flex !important; flex-direction: column; overflow: hidden !important;
    }
    body .ui.modal > .header { flex: 0 0 auto; padding: calc(18px + env(safe-area-inset-top, 0px)) 56px 16px 16px !important; font-size: 19px; overflow-wrap: anywhere; }
    body .ui.modal > .content { flex: 1 1 auto; min-height: 0 !important; max-height: none !important; overflow: auto !important; padding: 16px !important; -webkit-overflow-scrolling: touch; }
    body .ui.modal.pwa-no-heading > .content { padding-top: calc(56px + env(safe-area-inset-top, 0px)) !important; }
    body .ui.modal > .actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important; }
    body .ui.modal > .actions .button { margin: 0 !important; }
    body .ui.modal > .close.icon { position: absolute !important; top: env(safe-area-inset-top, 0px) !important; right: 4px !important; width: 48px; height: 48px; padding: 14px; margin: 0; color: #344054; z-index: 2; }
    body .ui.modal .fixed_part, body .ui.modal .scrollable_part { position: static !important; width: 100% !important; max-height: none !important; height: auto !important; overflow: visible !important; }
    body .ui.modal .ui.grid { margin: 0 !important; }
    body .ui.modal .ui.grid > .column, body .ui.modal .ui.grid > .row > .column { width: 100% !important; padding: 8px 0 !important; }
    body .ui.modal[data-view=login] { background: #222; color: white; }
    body .ui.modal[data-view=login] > .header { width: 100%; padding: calc(40px + env(safe-area-inset-top, 0px)) 24px 24px !important; }
    body .ui.modal[data-view=login] > .content { width: 100%; padding: 16px 24px !important; flex: 0 1 auto; }
    body .ui.modal[data-view=login] > .actions { width: 100%; padding: 16px 24px !important; }
    body .ui.modal[data-view=login] > .actions > .button { position: static !important; flex: 1 1 auto; }
    body .pwa-table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
    body .pwa-table-scroll > table { min-width: 640px; }
    body .dataTables_wrapper { max-width: 100%; }
    body .dataTables_scrollBody { -webkit-overflow-scrolling: touch; }
    body .dataTables_scrollBody td { height: 44px; }
    body .dataTables_scrollBody input:not([type=checkbox]):not([type=radio]) { min-height: 36px; font-size: 16px; }
    body .dataTables_info, body .ag-paging-panel { font-size: 12px; }
    body .ag-paging-panel { flex-wrap: wrap; height: auto; min-height: 44px; padding: 6px; gap: 6px; }
    body .ag-paging-panel > span { margin: 0 4px; }
    body .table_search { margin: 8px 0; }
    body .ui.form.table_search > .fields { align-items: flex-end; gap: 8px; }
    body .ui.form.table_search > .fields > .field { flex: 1 1 125px !important; width: auto !important; margin: 0 !important; }
    body .ui.form.table_search > .fields > .field:last-child { flex: 0 0 auto !important; }
    body .ui.form.table_search > .fields > .field > label { font-size: 12px; }
    body .ui.form.table_search input { padding: 10px !important; }
    body .dataTables_filter, body .dataTables_length { float: none; text-align: left; margin: 6px 0; }
    body .ag-theme-balham { max-width: 100%; min-width: 0; }
    body .ag-body-viewport, body .ag-center-cols-viewport { -webkit-overflow-scrolling: touch; }
    body .notification { width: 100% !important; max-width: 100%; border-radius: 0; }
    body .pwa-install { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 24px); }
    body.pwa-mobile-modal .pwa-install { display: none; }
    body #page_chat .direct-chat-row { padding: 8px; height: 100%; }
    body #page_chat .chat-sidebar-column, body #page_chat .chat-conversation-column { width: 100% !important; padding: 0 !important; height: 100%; }
    body #page_chat .chat-conversation-column { display: none; }
    body #page_chat.pwa-chat-detail .chat-sidebar-column { display: none; }
    body #page_chat.pwa-chat-detail .chat-conversation-column { display: block; }
    body #page_chat, body #page_chat .chat-sidebar { height: 100%; }
    body #page_chat .chat-sidebar { display: flex; flex-direction: column; }
    body #page_chat .chat-sidebar > .box-body { min-height: 0; flex: 1; overflow: auto; }
    body #page_chat .nav.users { height: auto; overflow: visible; }
    body #page_chat.pwa-chat-detail .direct-chat { display: flex !important; height: 100%; flex-direction: column; }
    body #page_chat .direct-chat > .box-header { flex: 0 0 auto; padding-left: 52px; min-height: 52px; }
    body #page_chat .direct-chat > .box-body { flex: 1; min-height: 0; height: auto !important; overflow: auto; }
    body #page_chat .direct-chat > .box-footer { flex: 0 0 auto; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    body #page_chat .direct-chat-messages { height: auto !important; min-height: 100%; }
    body #page_chat .chat-input { font-size: 16px; }
    body #page_chat .chat-input-hint { display: none; }
    body #page_chat .chat-search-controls { max-width: 100%; }
    .pwa-mobile-chat-back { display: block; position: absolute; left: 4px; top: 4px; width: 44px; height: 44px; border: 0; background: transparent; font-size: 26px; color: #17618b; }
}
@media (max-width: 767px), (max-width: 1023px) and (pointer: coarse) {
    body .ui.modal[data-view=login] > .maxWidth500 { margin: 0 auto !important; }
    body .pwa-table-scroll > table { display: table !important; }
    body .pwa-table-scroll > table tr { display: table-row !important; }
    body .pwa-table-scroll > table th, body .pwa-table-scroll > table td { display: table-cell !important; }
}
.pwa-mobile-actions { display: none; }
@media (max-width: 767px), (max-width: 1023px) and (pointer: coarse) {
    body .content-header.pwa-mobile-toolbar { overflow: visible; }
    body .pwa-mobile-toolbar:not(.pwa-toolbar-expanded) > :not(.pwa-mobile-actions):not(style):not(script) { display: none !important; }
    body .pwa-mobile-actions { display: block; width: 100%; border: 1px solid #d5dde5; border-radius: 8px; background: #fff; color: #263442; text-align: left; padding: 12px; font-size: 15px; min-height: 44px; }
    body .pwa-mobile-actions::after { content: '⌄'; float: right; }
    body .pwa-toolbar-expanded > .pwa-mobile-actions::after { content: '⌃'; }
}

@media (max-width: 767px), (max-width: 1023px) and (pointer: coarse) {
    body .content-header .ui.button > .pwa-button-content { display: flex; align-items: center; justify-content: center; gap: 8px; height: 100%; width: 100%; line-height: 20px; }
    body .content-header .ui.button > .pwa-button-content > i.icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 18px; width: 18px; height: 20px; margin: 0 !important; line-height: 1; }
    body #waybills_section > .pwa-waybill-tools { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; align-items: end; }
    body .pwa-waybill-tools > .pwa-desktop-label { display: none; }
    body .pwa-waybill-tools > .pwa-primary-action { grid-column: span 3; order: 0; width: 100%; padding: 10px !important; }
    body .pwa-waybill-tools > .pwa-setting-field { grid-column: span 3; order: 1; }
    body .pwa-waybill-tools > .pwa-filter-action { grid-column: span 2; order: 2; padding: 8px !important; font-size: 13px; }
    body .pwa-waybill-tools > .pwa-selected-field { grid-column: span 6; order: 3; }
    body .pwa-waybill-tools > .pwa-total-field { grid-column: span 3; order: 4; }
    body .pwa-waybill-tools .pwa-field-label { display: block; margin: 2px 0 4px; font-size: 12px; font-weight: 600; color: #596674; }
    body .pwa-waybill-tools > .ui.form { min-width: 0; }
    body .pwa-waybill-tools > .ui.form > .ui.input,
    body #waybills_section .pwa-waybill-tools .ui.dropdown.currentPoint,
    body .pwa-waybill-tools > .ui.form select { width: 100% !important; }
    body .pwa-waybill-tools > .ui.form input { width: 100%; box-sizing: border-box; }
    body #waybillsNewTable .ui.simple.dropdown > .menu { display: none !important; }
    body .pwa-row-menu-backdrop { position: fixed; inset: 0; background: #0006; border: 0; z-index: 1900; }
    body .ui.pwa-row-menu { position: fixed; z-index: 1901; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); margin: 0 auto; width: auto; max-width: 440px; max-height: calc(var(--pwa-viewport-height, 100dvh) - 32px - env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; background: white; border-radius: 14px; box-shadow: 0 12px 48px #0004; overflow: hidden; }
    body .pwa-row-menu-heading { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid #e5e9ef; font-size: 16px; }
    body .pwa-row-menu-heading button { flex: 0 0 44px; width: 44px; height: 44px; border: 0; border-radius: 8px; background: #f0f3f6; font-size: 26px; color: #344054; }
    body .ui.pwa-row-menu > .menu { display: block !important; position: static !important; min-height: 0; width: 100%; margin: 0; padding: 6px; overflow-y: auto; overscroll-behavior: contain; box-sizing: border-box; }
    body .ui.pwa-row-menu > .menu > .item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 12px; line-height: 20px; font-size: 15px; color: #263442; white-space: normal; border-radius: 6px; text-decoration: none; }
    body .ui.pwa-row-menu > .menu > .item > i.icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 20px; width: 20px; height: 20px; line-height: 1; margin: 0; }
    body .ui.pwa-row-menu > .menu > .item.disabled { color: #9ca3af; cursor: default; }
    body .ui.pwa-row-menu > .menu > .item:not(.disabled):hover { background: #f0f4f8; }
}
