.mobile-nav-toggle,
.dashboard-recent-cards { display: none; }

@media (max-width: 767px) {
    html[data-mobile-layout="modern"] {
        --rd-mobile-gutter: 14px;
        --rd-mobile-toolbar: 62px;
    }

    html[data-mobile-layout="modern"] .topbar {
        min-height: var(--rd-mobile-toolbar);
        gap: 6px;
        padding: max(8px, env(safe-area-inset-top))
            max(var(--rd-mobile-gutter), env(safe-area-inset-right)) 8px
            max(var(--rd-mobile-gutter), env(safe-area-inset-left));
    }

    html[data-mobile-layout="modern"]:not([data-mobile-nav-ready="true"]) .topbar {
        position: relative;
    }

    html[data-mobile-layout="modern"] .topbar > .brand {
        flex: 1 1 0;
        order: 0;
        min-width: 0;
        font-size: 17px;
    }

    html[data-mobile-layout="modern"] .brand-mark { flex: 0 0 32px; }
    html[data-mobile-layout="modern"] .brand > span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    html[data-mobile-layout="modern"][data-mobile-nav-ready="true"] .topbar > .mobile-nav-toggle {
        order: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 44px;
        padding: 7px 11px;
        border: 1px solid rgb(255 255 255 / 20%);
        border-radius: 10px;
        color: #fff;
        background: rgb(255 255 255 / 8%);
        font-family: var(--rd-menu-font, inherit);
        font-size: 14px;
        font-weight: 700;
        white-space: nowrap;
    }

    html[data-mobile-layout="modern"] .mobile-nav-toggle[aria-expanded="true"] {
        border-color: #82c8df;
        background: rgb(255 255 255 / 18%);
    }

    html[data-mobile-layout="modern"] .mobile-nav-toggle:focus-visible,
    html[data-mobile-layout="modern"] .topnav-link:focus-visible {
        outline: 2px solid #99ddf2;
        outline-offset: -2px;
    }

    html[data-mobile-layout="modern"] .topbar > .user-menu {
        order: 2;
        margin-inline-start: 0;
    }

    html[data-mobile-layout="modern"] .topbar > .topnav {
        order: 3;
        flex-basis: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        gap: 6px;
        padding: 9px 0 3px;
        border-top: 1px solid rgb(255 255 255 / 20%);
    }

    html[data-mobile-layout="modern"][data-mobile-nav-ready="true"] .topbar > .topnav {
        display: none;
        max-height: min(58vh, 430px);
        overflow: auto;
        overscroll-behavior: contain;
    }

    html[data-mobile-layout="modern"][data-mobile-nav-ready="true"] .mobile-nav-toggle[aria-expanded="true"] ~ .topnav {
        display: grid;
    }

    html[data-mobile-layout="modern"] .topnav-link,
    html[data-mobile-layout="modern"] .topnav-dropdown > summary {
        min-height: 44px;
        padding: 9px 10px;
        border-radius: 9px;
        background: rgb(255 255 255 / 6%);
        white-space: normal;
        overflow-wrap: anywhere;
    }

    html[data-mobile-layout="modern"] .topnav-dropdown > summary {
        display: flex;
        justify-content: space-between;
    }

    html[data-mobile-layout="modern"] .topnav-dropdown-caret { flex: 0 0 7px; }
    html[data-mobile-layout="modern"] .topnav-dropdown[open] { grid-column: 1 / -1; }
    html[data-mobile-layout="modern"] .topnav-dropdown[open] .topnav-submenu {
        border-radius: 10px;
        box-shadow: none;
    }
    html[data-mobile-layout="modern"] .topnav-submenu a { min-height: 44px; }

    html[data-mobile-layout="modern"] .page-shell {
        width: auto;
        min-width: 0;
        margin: 18px max(var(--rd-mobile-gutter), env(safe-area-inset-right))
            max(32px, env(safe-area-inset-bottom)) max(var(--rd-mobile-gutter), env(safe-area-inset-left));
    }

    html[data-mobile-layout="modern"] .page-shell-auth {
        width: min(420px, calc(100% - 2 * var(--rd-mobile-gutter)));
        margin: 7vh auto 30px;
    }

    html[data-mobile-layout="modern"] .page-heading {
        align-items: stretch;
        gap: 12px;
        margin-block-end: 16px;
    }

    html[data-mobile-layout="modern"] .page-heading h1,
    html[data-mobile-layout="modern"] .detail-key h1 {
        font-size: clamp(22px, 6vw, var(--rd-heading-size, 31px));
        overflow-wrap: anywhere;
    }

    html[data-mobile-layout="modern"] .page-heading p,
    html[data-mobile-layout="modern"] .panel-header,
    html[data-mobile-layout="modern"] .detail-meta {
        overflow-wrap: anywhere;
    }

    html[data-mobile-layout="modern"] .detail-key { flex-wrap: wrap; gap: 7px; }

    html[data-mobile-layout="modern"] .heading-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
        align-items: stretch;
        gap: 8px;
    }

    html[data-mobile-layout="modern"] .heading-actions > * { min-width: 0; }
    html[data-mobile-layout="modern"] .heading-actions form > .button { width: 100%; }
    html[data-mobile-layout="modern"] .page-shell .button {
        min-height: 44px;
        padding-block: 8px;
        text-align: center;
        line-height: 1.35;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    html[data-mobile-layout="modern"] .page-shell .button:hover { transform: none; }
    html[data-mobile-layout="modern"] .page-shell .button:focus-visible {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }

    html[data-mobile-layout="modern"] .page-shell :is(.card, .panel, .grid, .detail-hero, .section-stack) {
        min-width: 0;
    }
    html[data-mobile-layout="modern"] .page-shell :is(.card, .panel) {
        border-radius: 14px;
        box-shadow: 0 3px 14px rgb(24 34 48 / 6%);
    }
    html[data-mobile-layout="modern"] .panel-header { gap: 8px 12px; flex-wrap: wrap; }
    html[data-mobile-layout="modern"] .panel-header h2 { font-size: 17px; }
    html[data-mobile-layout="modern"] .panel-body,
    html[data-mobile-layout="modern"] .card { padding: 14px; }
    html[data-mobile-layout="modern"] .section-stack,
    html[data-mobile-layout="modern"] .detail-hero { gap: 14px; }

    html[data-mobile-layout="modern"] .dashboard-stats { gap: 10px; margin-block-end: 15px; }
    html[data-mobile-layout="modern"] .stat-card {
        min-width: 0;
        padding: 12px;
        border-radius: 13px;
        background: linear-gradient(165deg, #f3f9fc, #fff 76%);
    }
    html[data-mobile-layout="modern"] .stat-card .value {
        color: var(--primary-dark);
        font-size: 26px;
        font-variant-numeric: tabular-nums;
    }

    html[data-mobile-layout="modern"] .dashboard-recent-table { display: none; }
    html[data-mobile-layout="modern"] .dashboard-recent-cards {
        display: grid;
        padding: 0;
        margin: 0;
        list-style: none;
    }
    html[data-mobile-layout="modern"] .dashboard-recent-cards li + li { border-top: 1px solid var(--line); }
    html[data-mobile-layout="modern"] .dashboard-recent-job {
        display: grid;
        gap: 5px;
        padding: 13px 14px;
        color: var(--ink);
        text-decoration: none;
        overflow-wrap: anywhere;
    }
    html[data-mobile-layout="modern"] .dashboard-recent-job:focus-visible {
        outline: 2px solid var(--primary);
        outline-offset: -2px;
    }
    html[data-mobile-layout="modern"] .dashboard-recent-job-head,
    html[data-mobile-layout="modern"] .dashboard-recent-job-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 4px 9px;
    }
    html[data-mobile-layout="modern"] .dashboard-recent-job-head > strong { color: var(--primary-dark); }
    html[data-mobile-layout="modern"] .dashboard-recent-job-head .pill {
        max-width: 100%;
        white-space: normal;
    }
    html[data-mobile-layout="modern"] .dashboard-recent-job-meta { justify-content: start; }

    html[data-mobile-layout="modern"] .page-shell :is(
        input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
        input[type="number"], input[type="date"], input[type="search"], input[type="url"],
        input:not([type]), select, textarea
    ) {
        min-width: 0;
        min-height: 44px;
        font-size: 16px;
    }
    html[data-mobile-layout="modern"] .page-shell textarea { min-height: 92px; }
    html[data-mobile-layout="modern"] .page-shell input[type="date"] { max-width: 100%; }
    html[data-mobile-layout="modern"] .page-shell input[type="file"] { min-height: 44px; max-width: 100%; }
    html[data-mobile-layout="modern"] .page-shell input[type="file"]::file-selector-button { min-height: 38px; }
    html[data-mobile-layout="modern"] .page-shell .check-item { min-height: 44px; }
    html[data-mobile-layout="modern"] .page-shell .checkbox-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    }
    html[data-mobile-layout="modern"] .filter-bar {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
        gap: 10px;
        padding: 12px;
    }
    html[data-mobile-layout="modern"] .filter-bar .field:has(input[name="q"]) { grid-column: 1 / -1; }
    html[data-mobile-layout="modern"] .form-actions { flex-wrap: wrap; gap: 8px; }
    html[data-mobile-layout="modern"] .settings-save-bar { top: calc(var(--rd-mobile-toolbar) + env(safe-area-inset-top)); }

    html[data-mobile-layout="modern"] .page-shell .table-wrap {
        min-width: 0;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
    }
    html[data-mobile-layout="modern"] .page-shell .table-wrap:focus-visible {
        outline: 2px solid var(--primary);
        outline-offset: -2px;
    }
    html[data-mobile-layout="modern"] .page-shell .table-wrap :is(th, td) {
        padding: 9px 10px;
    }
    html[data-mobile-layout="modern"] .page-shell .table-wrap th { white-space: nowrap; }
    html[data-mobile-layout="modern"] .page-shell .table-wrap td { overflow-wrap: break-word; }
    html[data-mobile-layout="modern"] .page-shell .table-wrap :is(th, td).hide-mobile { display: table-cell; }
    html[data-mobile-layout="modern"] .page-shell .table-wrap :where(table:not([class])) { min-width: min(100%, 320px); }
    html[data-mobile-layout="modern"] .page-shell .table-wrap :where(table:has(thead tr > th:nth-child(5))) { min-width: 550px; }
    html[data-mobile-layout="modern"] .page-shell .table-wrap .po-items-table { min-width: 790px; }
    html[data-mobile-layout="modern"] .page-shell .table-wrap .po-items-editable { min-width: 945px; }
    html[data-mobile-layout="modern"] .page-shell .table-wrap .po-sis-table { min-width: 820px; }
    html[data-mobile-layout="modern"] .page-shell .table-wrap .po-order-table { min-width: 560px; }
    html[data-mobile-layout="modern"] .po-order-table tr > :last-child {
        position: sticky;
        inset-inline-end: 0;
        width: 100px;
        background: var(--surface);
        box-shadow: -1px 0 var(--line);
        text-align: center;
    }
    html[data-mobile-layout="modern"] .po-order-table thead tr > :last-child { background: var(--surface-soft); }

    html[data-mobile-layout="modern"] .po-workspace .po-panel { margin-block-end: 14px; }
    html[data-mobile-layout="modern"] :is(.po-create-order, .po-upload) {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }
    html[data-mobile-layout="modern"] .po-catalog-search,
    html[data-mobile-layout="modern"] .po-cost-form .po-field-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    html[data-mobile-layout="modern"] .po-source-grid { gap: 8px; }
    html[data-mobile-layout="modern"] .po-source-grid > div { padding: 9px; }
    html[data-mobile-layout="modern"] .po-source-grid dd { font-size: 16px; }
    html[data-mobile-layout="modern"] :is(#po-sis-import, #po-catalog, #po-items, #po-cost, #po-pi-preview, #repair-details, #repair-status) {
        scroll-margin-top: calc(var(--rd-mobile-toolbar) + env(safe-area-inset-top) + 12px);
    }
}
