/* Mobile-only adaptations. Desktop and tablet layouts remain authoritative. */
.mobile-workspace-notice {
    display: none;
}

@media (max-width: 760px) {
    html,
    body {
        min-width: 0;
        overflow-x: hidden;
    }

    .page {
        min-height: 100dvh;
    }

    .page main {
        min-width: 0;
        width: calc(100% - 56px);
    }

    .page .sidebar-shell {
        flex: 0 0 56px;
        width: 56px;
    }

    .page .top-row {
        min-height: 40px;
    }

    .page .live-status {
        height: 30px;
        margin: 0 3px;
        min-height: 30px;
        min-width: 30px;
        padding: 0;
        width: 30px;
    }

    .page .live-status-text,
    .page .theme-toggle-text {
        display: none;
    }

    .page .theme-toggle {
        min-width: 40px;
        padding: 0;
        width: 40px;
    }

    .page .open-tab {
        min-width: 82px;
        padding-left: 10px;
    }

    .page .open-tab.active {
        min-width: 104px;
    }

    .page .close-tab {
        margin-left: 4px;
    }

    .nav-panel,
    .nav-panel.collapsed {
        overflow: visible;
    }

    .nav-panel .brand-copy,
    .nav-panel .panel-toggle,
    .nav-panel .user-meta {
        display: none;
    }

    .nav-panel .nav-scrollable {
        overflow: visible;
    }

    .nav-panel .menu-items {
        display: none;
    }

    .nav-panel .menu-group {
        display: flex;
        justify-content: center;
        position: relative;
        width: 40px;
    }

    .nav-panel .flyout-menu {
        background: linear-gradient(180deg, var(--nav-panel-bg), var(--nav-panel-bg-2));
        border: 0;
        border-radius: 0 4px 4px 0;
        box-shadow: 12px 16px 28px rgba(2, 10, 32, 0.24);
        left: 48px;
        min-width: 220px;
        padding: 14px 16px;
        position: absolute;
        top: 0;
        z-index: 260;
    }

    .nav-panel .flyout-menu::before {
        bottom: 0;
        content: "";
        left: -12px;
        position: absolute;
        top: 0;
        width: 12px;
    }

    .nav-panel .menu-group:hover .flyout-menu,
    .nav-panel .menu-group:focus-within .flyout-menu,
    .nav-panel .menu-group.expanded .flyout-menu {
        display: block;
    }

    .nav-panel .current-user {
        background: transparent;
        padding: 0;
        width: 40px;
    }

    .nav-panel .user-avatar {
        flex-basis: 32px;
        height: 32px;
        width: 32px;
    }

    .nav-panel .user-menu-button {
        height: 19px;
        right: -2px;
        top: -3px;
        width: 19px;
    }

    .nav-panel .user-action-menu {
        bottom: 0;
        left: 46px;
        right: auto;
        z-index: 280;
    }

    .page .notification-bell-shell .notification-panel {
        bottom: 8px;
        box-sizing: border-box;
        left: 64px;
        max-height: none;
        min-width: 0;
        position: fixed;
        right: 8px;
        top: 48px;
        width: auto;
        z-index: 600;
    }

    .notification-list {
        padding: 6px;
    }

    .notification-item {
        gap: 5px;
        padding: 6px;
    }

    .notification-item-main {
        gap: 7px;
        grid-template-columns: 28px minmax(0, 1fr) 6px;
    }

    .notification-avatar {
        height: 28px;
        width: 28px;
    }

    .global-alert-stack {
        align-items: stretch;
        left: 64px;
        right: 8px;
        top: 48px;
    }

    .global-alert {
        max-width: none;
        width: 100%;
    }

    .global-progress-shell {
        left: 64px;
        right: 8px;
        transform: none;
        width: auto;
    }

    .utility-page {
        height: auto;
        min-height: calc(100dvh - 40px);
        overflow: visible;
    }

    .utility-header {
        gap: 9px;
        grid-template-columns: minmax(0, 1fr);
        min-height: 0;
        padding: 10px 12px;
    }

    .page-breadcrumb-title {
        max-width: 100%;
        white-space: normal;
    }

    .page-breadcrumb-title .breadcrumb-root {
        font-size: 16px;
    }

    .page-breadcrumb-title .breadcrumb-current {
        font-size: 12px;
    }

    .utility-page .mode-banner-slot {
        justify-content: flex-start;
        min-width: 0;
        width: 100%;
    }

    .utility-page .mode-banner {
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .utility-page .header-status {
        flex-wrap: wrap;
        justify-self: stretch;
    }

    .utility-toolbar {
        align-items: stretch;
        flex-direction: column;
        padding: 8px;
    }

    .utility-page .filter-cluster,
    .utility-page .action-cluster {
        align-items: stretch;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .utility-page .search-field {
        grid-column: 1 / -1;
        min-width: 0;
        width: 100%;
    }

    .utility-page .tool-button {
        min-width: 0;
        width: 100%;
    }

    .utility-workspace {
        flex: 0 0 auto;
        grid-template-rows: auto minmax(320px, 55dvh);
        overflow: visible;
    }

    .utility-form,
    .product-form,
    .unit-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .utility-page .grid-panel {
        min-height: 320px;
    }

    .utility-page .table-scroll {
        min-height: 320px;
        overscroll-behavior-inline: contain;
    }

    .utility-table,
    .product-workspace .utility-table {
        min-width: max-content;
    }

    .unit-table {
        min-width: 360px;
        width: 100%;
    }

    .unit-table th,
    .unit-table td {
        width: auto;
    }

    .login-page {
        align-items: flex-start;
        min-height: 100dvh;
        overflow-y: auto;
        padding: 0;
    }

    .login-shell {
        box-shadow: none;
        grid-template-columns: minmax(0, 1fr);
        min-height: 100dvh;
        width: 100%;
    }

    .login-brand-panel {
        gap: 28px;
        min-height: 190px;
        padding: 22px;
    }

    .login-copy span {
        margin-bottom: 8px;
    }

    .login-copy h1 {
        font-size: 23px;
        line-height: 1.2;
    }

    .login-card-panel {
        align-items: flex-start;
        min-height: calc(100dvh - 190px);
        padding: 26px 20px;
    }

    .login-card {
        width: 100%;
    }

    .login-card-heading strong {
        font-size: 26px;
    }

    .dashboard-page {
        height: auto;
        min-height: calc(100dvh - 40px);
        overflow: visible;
    }

    .dashboard-header {
        gap: 12px;
        padding: 12px;
    }

    .current-work-project {
        align-items: flex-start;
        flex-direction: column;
    }

    .current-work-project strong {
        max-width: 100%;
    }

    .dashboard-filters {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
    }

    .dashboard-filters label,
    .dashboard-filters label.compact-filter {
        min-width: 0;
        width: 100%;
    }

    .kpi-grid,
    .kpi-grid.estimator-kpi-grid {
        gap: 8px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 8px;
    }

    .kpi-card {
        min-height: 92px;
        padding: 10px;
    }

    .kpi-card strong {
        font-size: 22px;
    }

    .dashboard-layout {
        display: flex;
        flex-direction: column;
        gap: 8px;
        overflow: visible;
        padding: 0 8px 8px;
    }

    .dashboard-panel,
    .selected-project-panel,
    .time-panel,
    .snapshot-panel {
        min-height: 260px;
    }

    .stage-pipeline {
        grid-template-columns: minmax(0, 1fr);
    }

    .projects-page,
    .default-cost-page,
    .material-page,
    .material-type-page,
    .options-page,
    .user-page,
    .email-setup-page,
    .transfer-items-page,
    .module-page,
    .change-password-page {
        height: auto;
        min-height: calc(100dvh - 40px);
        overflow: visible;
    }

    .projects-header,
    .cost-header,
    .material-header,
    .material-type-header,
    .transfer-header,
    .module-header,
    .email-header {
        gap: 9px;
        padding: 10px 12px;
    }

    .projects-header,
    .cost-header,
    .material-header,
    .material-type-header,
    .email-header {
        grid-template-columns: minmax(0, 1fr);
    }

    .projects-header .mode-banner-slot,
    .cost-header .mode-banner-slot,
    .material-header .mode-banner-slot,
    .material-type-header .mode-banner-slot,
    .email-header .mode-banner-slot,
    .projects-header .header-status,
    .cost-header .header-status,
    .material-header .header-status,
    .material-type-header .header-status,
    .email-header .header-status {
        justify-self: stretch;
        min-width: 0;
    }

    .projects-header .mode-banner,
    .cost-header .mode-banner,
    .material-header .mode-banner,
    .material-type-header .mode-banner,
    .email-header .mode-banner {
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .project-toolbar,
    .cost-toolbar,
    .material-toolbar,
    .material-type-toolbar,
    .module-toolbar,
    .email-toolbar {
        align-items: stretch;
        flex-direction: column;
        padding: 8px;
    }

    .project-toolbar .filter-cluster,
    .project-toolbar .action-cluster,
    .cost-toolbar .filter-cluster,
    .cost-toolbar .action-cluster,
    .material-toolbar .filter-cluster,
    .material-toolbar .action-cluster,
    .material-type-toolbar .filter-cluster,
    .material-type-toolbar .action-cluster,
    .email-toolbar .filter-cluster,
    .email-toolbar .action-cluster {
        align-items: stretch;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .project-toolbar .search-field,
    .cost-toolbar .search-field,
    .material-toolbar .search-field,
    .material-type-toolbar .search-field,
    .email-toolbar .search-field {
        grid-column: 1 / -1;
        min-width: 0;
        width: 100%;
    }

    .project-toolbar .tool-button,
    .cost-toolbar .tool-button,
    .material-toolbar .tool-button,
    .material-type-toolbar .tool-button,
    .email-toolbar .tool-button {
        min-width: 0;
        width: 100%;
    }

    .project-workspace,
    .cost-workspace,
    .material-type-body,
    .material-workspace,
    .user-workspace.utility-workspace,
    .email-workspace,
    .options-layout,
    .transfer-workspace {
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    .project-workspace .table-scroll,
    .cost-workspace .table-scroll,
    .material-workspace .table-scroll,
    .material-type-body .table-scroll,
    .user-workspace .table-scroll,
    .email-workspace .table-scroll {
        height: 48dvh;
        max-height: none;
        min-height: 300px;
    }

    .project-editor,
    .cost-editor,
    .history-panel,
    .finish-panel,
    .user-form-panel,
    .email-editor {
        border-left: 0;
        border-top: 1px solid var(--theme-border, #cfdbe7);
        max-height: none;
        min-height: 0;
    }

    .project-editor form,
    .cost-editor form,
    .project-editor .details-panel,
    .cost-editor .details-panel {
        height: auto;
        max-height: none;
    }

    .form-grid.compact,
    .material-form,
    .type-form-grid,
    .finish-form-grid,
    .identity-grid,
    .permission-grid,
    .email-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .user-form-panel,
    .email-editor {
        width: 100%;
    }

    .user-form-scroll {
        max-height: none;
        overflow: visible;
    }

    .check-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: none;
    }

    .material-workspace {
        grid-template-rows: auto auto;
    }

    .history-panel {
        min-height: 260px;
    }

    .transfer-header {
        align-items: stretch;
        flex-direction: column;
    }

    .transfer-project-tags {
        justify-content: flex-start;
    }

    .transfer-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }

    .transfer-list {
        min-height: 340px;
    }

    .transfer-actions {
        align-items: center;
        flex-direction: row;
        justify-content: center;
        min-height: 52px;
    }

    .module-page .stage-summary,
    .module-page .report-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .module-page .report-filters,
    .module-page .maintenance-side,
    .module-page .jobcost-side,
    .module-page .formula-preview,
    .module-page .help-side {
        max-height: none;
    }

    .change-password-body {
        align-items: flex-start;
        padding: 16px 10px;
    }

    .change-password-card {
        max-width: none;
        width: 100%;
    }

    .change-password-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .change-password-actions button {
        width: 100%;
    }

    .project-selector-backdrop {
        align-items: stretch;
        padding: 8px;
    }

    .project-selector-dialog {
        max-height: calc(100dvh - 16px);
        min-height: 0;
        min-width: 0;
        width: 100%;
    }

    .project-selector-dialog .selector-header {
        gap: 8px;
        grid-template-columns: minmax(0, 1fr) auto;
        min-height: 52px;
        padding: 8px 10px;
    }

    .project-selector-dialog .selector-stage-chip {
        display: none;
    }

    .project-selector-dialog .selector-toolbar {
        align-items: stretch;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        max-height: 36dvh;
        overflow-y: auto;
        padding: 8px;
    }

    .project-selector-dialog .selector-field,
    .project-selector-dialog .search-field {
        min-width: 0;
        width: 100%;
    }

    .project-selector-dialog .selector-body,
    .project-selector-dialog .report-export-body {
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow-y: auto;
    }

    .project-selector-dialog .selector-project-list {
        min-height: 280px;
    }

    .project-selector-dialog .export-options-grid,
    .project-selector-dialog .report-options-grid,
    .project-selector-dialog .export-option-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .project-selector-dialog .selector-footer {
        align-items: stretch;
        display: grid;
        gap: 8px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 8px;
    }

    .project-selector-dialog .selector-footer button {
        min-width: 0;
        width: 100%;
    }

    .module-page .table-scroll,
    .module-page .report-main,
    .module-page .help-main {
        max-width: 100%;
        overflow-x: auto;
    }

    .options-layout .color-option {
        grid-template-columns: minmax(92px, auto) minmax(0, 1fr) 54px;
    }

    .mobile-workspace-notice {
        align-items: center;
        background: var(--theme-bg, #eef3f7);
        color: var(--theme-text, #1d2731);
        display: flex;
        flex-direction: column;
        gap: 18px;
        justify-content: center;
        min-height: calc(100dvh - 40px);
        padding: 28px 22px;
        text-align: center;
    }

    .mobile-workspace-notice > div {
        max-width: 420px;
    }

    .mobile-workspace-icon {
        background: var(--theme-primary, #1f5c9d);
        display: inline-block;
        height: 52px;
        width: 52px;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M4 3h16v11H4V3Zm2 2v7h12V5H6Zm3 11h6v2h4v2H5v-2h4v-2Zm2-9h2v3h3v2h-5V7Z'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M4 3h16v11H4V3Zm2 2v7h12V5H6Zm3 11h6v2h4v2H5v-2h4v-2Zm2-9h2v3h3v2h-5V7Z'/%3E%3C/svg%3E") center / contain no-repeat;
    }

    .mobile-workspace-eyebrow {
        color: var(--theme-primary, #1f5c9d);
        display: block;
        font-size: 11px;
        font-weight: 700;
        margin-bottom: 8px;
        text-transform: uppercase;
    }

    .mobile-workspace-notice h1 {
        color: var(--theme-heading, #172334);
        font-size: 24px;
        line-height: 1.2;
        margin: 0;
    }

    .mobile-workspace-notice p {
        color: var(--theme-muted, #66788d);
        font-size: 14px;
        line-height: 1.55;
        margin: 10px 0 0;
    }

    .mobile-workspace-notice a {
        align-items: center;
        background: var(--theme-primary, #1f5c9d);
        border: 1px solid var(--theme-primary-strong, #184c84);
        border-radius: 4px;
        color: #ffffff;
        display: inline-flex;
        font-weight: 700;
        min-height: 40px;
        padding: 0 16px;
        text-decoration: none;
    }

    .takeoff-page {
        display: none !important;
    }
}

@media (max-width: 420px) {
    .kpi-grid,
    .kpi-grid.estimator-kpi-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .utility-page .filter-cluster,
    .utility-page .action-cluster,
    .project-toolbar .filter-cluster,
    .project-toolbar .action-cluster,
    .cost-toolbar .filter-cluster,
    .cost-toolbar .action-cluster,
    .material-toolbar .filter-cluster,
    .material-toolbar .action-cluster,
    .material-type-toolbar .filter-cluster,
    .material-type-toolbar .action-cluster,
    .email-toolbar .filter-cluster,
    .email-toolbar .action-cluster,
    .check-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
