/* Shared phone presentation. Screen-only rules preserve report printing. */
@media screen and (max-width: 1024px) {
    :root {
        --primary-color: #007aff;
        --primary-hover: #0062cc;
        --bg-body: #f2f2f7;
        --bg-surface: #ffffff;
        --text-main: #1c1c1e;
        --text-secondary: #636366;
        --border-color: #e5e5ea;
        --wb-bg: #f2f2f7;
        --wb-panel: #ffffff;
        --wb-panel-soft: #f8f8fa;
        --wb-ink: #1c1c1e;
        --wb-muted: #636366;
        --wb-line: #e5e5ea;
        --wb-brand: #007aff;
        --wb-brand-soft: #eef5ff;
        --header-height: calc(64px + env(safe-area-inset-top, 0px));
    }

    body {
        font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
        background: #f2f2f7;
        color: #1c1c1e;
        -webkit-text-size-adjust: 100%;
        line-height: 1.55;
    }

    [hidden] {
        display: none !important;
    }

    .main-content {
        width: 100%;
        min-width: 0;
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
        padding-bottom: max(24px, env(safe-area-inset-bottom)) !important;
    }

    .top-nav {
        padding-top: env(safe-area-inset-top);
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        background: rgba(250, 250, 252, 0.96);
        border-bottom-color: #e5e5ea;
    }

    .page-view,
    .page-view .card,
    .page-view .table-container,
    .modal-body,
    .report-content,
    .report-product {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .card,
    .workbench-panel,
    .workbench-plan-bar,
    .crm-customer-panel {
        border-radius: 18px;
        border-color: #e5e5ea;
        box-shadow: 0 2px 10px rgba(28, 28, 30, 0.035);
    }

    .card-header,
    .filter-bar,
    .workbench-results-toolbar,
    .workbench-plan-actions,
    .crm-customer-panel-head,
    .crm-section-head,
    .crm-form-actions,
    .profile-report-actions {
        flex-wrap: wrap;
        gap: 10px;
    }

    .page-view .card-header {
        align-items: flex-start;
    }

    .btn {
        border-radius: 12px;
        min-width: 44px;
        box-shadow: none;
        white-space: normal;
    }

    button,
    .btn,
    .nav-link,
    .report-button,
    .community-section-nav button,
    .community-feed-tabs button,
    .project-detail-tabs button {
        min-height: 44px !important;
        min-width: 44px;
        touch-action: manipulation;
    }

    .btn:hover,
    .btn-primary:hover {
        transform: none;
    }

    .btn:active {
        opacity: 0.78;
    }

    .crm-customer-search .btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea,
    .form-control {
        min-width: 0;
        max-width: 100%;
        font-size: 16px !important;
    }

    .form-control,
    .community-top-search {
        min-height: 44px;
        border-radius: 12px;
    }

    label:has(input[type="checkbox"]),
    label:has(input[type="radio"]) {
        min-height: 44px;
        align-content: center;
    }

    .nav-link {
        border-radius: 12px;
    }

    .nav-link.active {
        background: #eef5ff;
        color: #0062cc;
    }

    .sidebar {
        padding-top: max(16px, env(safe-area-inset-top));
        background: #fafafc;
    }

    .sidebar-overlay {
        background: rgba(28, 28, 30, 0.32);
    }

    .mobile-stack,
    .grid-2,
    #aiPackagePlatformPanel,
    #aiPackageOrgPanel,
    #aiAllocationGroupForm,
    #aiTemplateForm,
    #aiUserAllocationForm,
    #orgMemberInviteComposer,
    .project-detail-metrics,
    .project-detail-compare,
    .project-detail-evidence-grid,
    .case-detail-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .mobile-stack > *,
    .grid-2 > *,
    .crm-customer-shell > *,
    .community-main-grid > *,
    .advisor-crm-queues > * {
        min-width: 0;
    }

    .table-container,
    .overview-table-wrap,
    .compare-table-wrap,
    .report-product-table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-container .btn {
        white-space: nowrap;
    }

    .custom-table th,
    .custom-table td {
        overflow-wrap: normal;
        word-break: normal;
    }

    #userTable {
        min-width: 1040px;
    }

    #userTable th:nth-child(2),
    #userTable td:nth-child(2) {
        min-width: 160px;
    }

    .toast-container {
        top: auto;
        bottom: max(16px, env(safe-area-inset-bottom));
        left: 16px;
        right: 16px;
    }

    .toast-message {
        width: 100%;
        min-width: 0;
        max-width: none;
        padding: 12px 16px;
        border-radius: 16px;
        pointer-events: none;
    }

    body.has-support-org-context {
        --header-height: calc(112px + env(safe-area-inset-top, 0px));
    }

    .has-support-org-context .top-nav {
        flex-wrap: wrap;
        align-content: center;
        row-gap: 0;
    }

    .has-support-org-context .support-org-top-banner {
        order: 4;
        flex: 1 0 100%;
        min-height: 44px;
        max-width: none;
        margin-left: 0;
    }

    #page-workbench #resultsTiered,
    #page-workbench .results-section > .result-col,
    #page-workbench #resultsOfficial,
    #page-workbench #resultsInternal {
        max-height: none;
        height: auto;
        overflow-y: visible;
    }

    #page-profile .profile-report-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .project-detail-hero,
    .project-detail-actions,
    .drawer-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .drawer-header {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .drawer-content {
        min-height: 0;
        padding: 16px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }

    .project-drawer {
        width: 100%;
        max-width: 100vw;
        height: 100dvh;
    }

    .modal-content,
    .login-card {
        border-radius: 22px;
    }

    .modal-header h3 {
        flex: 1;
        min-width: 0;
    }

    .modal-header > button {
        min-width: 44px;
        flex-shrink: 0;
    }

    .modal-body .mobile-stack {
        gap: 12px;
    }

    .modal-content > form {
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow-y: auto;
    }

    .modal-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .login-container {
        background: #f2f2f7;
    }

    .login-container::before {
        display: none;
    }

    .login-showcase {
        padding: 0;
    }

    .login-brand-row {
        flex-direction: row;
        text-align: left;
        gap: 12px;
    }

    .login-brand-logo {
        width: 64px;
        border-radius: 14px;
    }

    .login-product-name {
        font-size: 22px;
    }

    .login-product-name br {
        display: none;
    }

    .login-product-sub {
        font-size: 12px;
        margin-top: 4px;
    }

    .login-card {
        padding: 24px 20px;
        box-shadow: 0 4px 24px rgba(28, 28, 30, 0.04);
    }

    .login-card-head h2 {
        font-size: 24px;
    }

    .official-hero-title,
    .community-product-hero h1 {
        font-size: clamp(28px, 8vw, 38px);
        letter-spacing: -0.025em;
    }

    .official-entry-panel,
    .official-library-card,
    .community-feed-post,
    .community-composer,
    .community-post-dialog {
        border-radius: 18px;
        border-color: #e5e5ea;
    }

    .community-feed-page {
        background: #f2f2f7;
    }

    .community-feed-post {
        grid-template-columns: 44px minmax(0, 1fr);
    }

    .community-app-topbar {
        padding-top: max(10px, env(safe-area-inset-top));
        background: rgba(250, 250, 252, 0.96);
    }

    .community-top-search input {
        width: 100%;
    }

    .community-feed-shell,
    .community-post-main,
    .community-composer > * {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .community-section-nav,
    .community-feed-tabs {
        -webkit-overflow-scrolling: touch;
        scroll-padding-inline: 12px;
    }

    .client-report-app {
        padding: 12px 12px max(28px, env(safe-area-inset-bottom));
    }

    .report-content {
        padding: 18px;
        border-radius: 20px;
    }

    .report-product {
        padding: 18px;
        border-radius: 20px;
        border-color: #e5e5ea;
    }

    .report-content .report-actions,
    .client-report-feedback-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .report-product-course-grid,
    .program-grid,
    .project-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .client-report-title {
        font-size: 28px;
        letter-spacing: -0.02em;
    }

    .report-button {
        border-radius: 12px;
    }
}

@media screen and (max-width: 1024px) and (max-height: 480px) {
    .login-showcase {
        display: none;
    }

    .login-layout {
        gap: 0;
    }
}
