/* Shared mobile shell. Loaded after the desktop theme in every entry point. */
.mobile-nav, .sidebar-backdrop, .mobile-record-label, .mobile-map-tabs, .touch-task-edit { display: none; }
.mobile-cell-value { min-width: 0; }
.app-main, .page-content, .card, .card-head > div { min-width: 0; }
.auth-page:before, .auth-page:after { display: none; }
:where(button, a, input, select, textarea):focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
.contract-map-scroll, .schedule-scroll, .table-wrap { overscroll-behavior-x: contain; }

@media (max-width: 1023px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 84px; }
  .app-body { display: block; font-size: 16px; }
  .app-body .app-main { width: 100%; margin-left: 0; min-width: 0; }
  .app-body .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(320px, calc(100vw - 48px));
    height: 100vh; height: 100dvh; z-index: 150; transform: translateX(-105%);
    visibility: hidden; overflow-y: auto; overscroll-behavior: contain;
    padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
    transition: transform .2s ease; box-shadow: none;
  }
  .app-body.sidebar-open .sidebar { transform: none; visibility: visible; box-shadow: 16px 0 50px #152a4429; }
  /* Scroll the menu itself so the close button and current module remain reachable. */
  .app-body .sidebar.sidebar-scrollable { min-height: 0; overflow: hidden; }
  .app-body .sidebar-scrollable > .sidebar-menu { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scroll-padding-block: 8px; }
  .sidebar .sidebar-brand { flex-shrink: 0; height: auto; min-height: 66px; padding: 10px 52px 18px 12px; }
  .sidebar .sidebar-nav { flex-shrink: 0; }
  .sidebar .nav-item { min-height: 48px; font-size: 16px; padding: 10px 14px; }
  .sidebar .sidebar-bottom { position: static; margin-top: 24px; flex-shrink: 0; }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; border: 0; background: #15243866; z-index: 140; }
  .app-body .mobile-menu, .app-body .mobile-close { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; flex: 0 0 44px; border: 1px solid #dce3ee; border-radius: 12px; background: #fff; color: #233957; margin: 0; }
  .app-body .mobile-close { position: absolute; right: 4px; top: 7px; }
  .app-body .topbar { display: flex; position: sticky; top: 0; z-index: 50; height: auto; min-height: 64px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; gap: 12px; background: #ffffffed; backdrop-filter: blur(16px); }
  .app-body .breadcrumbs { min-width: 0; flex: 1; font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
  .breadcrumbs > span, .breadcrumbs > b, .topbar .profile-copy, .topbar-actions > .icon-button { display: none; }
  .app-body .topbar-actions, .app-body .profile-menu { display: flex; gap: 6px; padding: 0; border: 0; }
  .app-body .topbar-actions > .icon-button[title], .app-body .topbar-actions > .notification { display: none; }
  .topbar .avatar { width: 34px; height: 34px; }
  .topbar .icon-button { width: 44px; height: 44px; }
  .app-body .page-content, .app-body.screen-production .page-content { width: 100%; max-width: none; padding: 22px 20px 32px; }
  .app-body.has-mobile-nav .page-content { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .mobile-nav { position: fixed; z-index: 80; inset: auto 0 0; display: flex; justify-content: space-around; gap: 4px; padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border-top: 1px solid #dde4ee; background: #fffffff5; backdrop-filter: blur(18px); }
  .mobile-nav > a, .mobile-nav > button { flex: 1; min-width: 0; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 6px 2px; border: 0; border-radius: 12px; color: #59677d; background: transparent; font-size: 13px; line-height: 1.3; }
  .mobile-nav .icon { width: 22px; height: 22px; }
  .mobile-nav .is-active { background: #eaf1ff; color: #2454a4; font-weight: 700; }
  .app-body .dashboard-grid, .app-body .dashboard-grid.equal, .app-body .detail-grid,
  .app-body .module-two-col, .app-body .commissioning-layout, .app-body .delivery-layout,
  .app-body .repair-layout, .app-body .report-grid, .app-body .employee-board, .app-body .owner-layout,
  .app-body .contract-demo-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .app-body .card-head { flex-wrap: wrap; gap: 14px; }
  .app-body .contract-map-layout { grid-template-columns: minmax(0, 1fr); }
  .app-body .module-guide { display: none; }
  .app-body .game-quest-strip { padding: 12px; margin-bottom: 18px; }
  .app-body .quest-strip-label, .app-body .quest-strip-score { display: none; }
  .app-body .quest-strip-path { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; flex-wrap: nowrap; }
  .quest-strip-path > * { flex-shrink: 0; }
  .app-body .button, .app-body .action-chip { min-height: 44px; padding: 10px 14px; font-size: 16px; line-height: 1.4; white-space: normal; text-align: center; }
  .app-body .button .icon { flex: 0 0 18px; }
  .page-heading > div, .toolbar > div, .toolbar form, .search-box, .search-box input { min-width: 0; }
  .app-body .toolbar-left, .app-body .toolbar-right { flex-wrap: wrap; gap: 10px; }
  .app-body input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .app-body select, .app-body textarea,
  .auth-page input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .auth-page select { max-width: 100%; min-width: 0; min-height: 48px; font-size: 16px; }
  .app-body input[type=checkbox], .app-body input[type=radio] { min-height: 20px; width: 20px; height: 20px; flex: 0 0 20px; }
  .app-body .permission-option, .app-body .role-option { min-height: 48px; padding: 12px; }
  .app-body .game-banner { flex-wrap: wrap; }
  .app-body .table-wrap { max-width: 100%; }
  .touch-task-edit { display: inline-flex; }
  .app-body .mission-actions { flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
  .app-body .mission-actions .button { min-height: 44px; font-size: 15px; }
  .preview-body .preview-ribbon { display: none; }
}

@media (max-width: 760px) {
  .app-body .page-content, .app-body.screen-production .page-content { padding: 18px 14px 28px; }
  .app-body.has-mobile-nav .page-content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .app-body .page-heading { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 20px; }
  .app-body .page-heading h1, .app-body .contract-map-toolbar-title h1 { font-size: 27px; line-height: 1.35; letter-spacing: -.4px; overflow-wrap: anywhere; }
  .app-body .page-heading p { font-size: 16px; line-height: 1.65; }
  .app-body .eyebrow, .app-body .section-kicker { display: none; }
  .app-body.screen-dashboard .page-heading { min-height: 0; padding: 22px 18px; }
  .app-body.screen-dashboard .page-heading:after { display: none; }
  .app-body .page-heading-actions, .app-body .contract-plan-heading-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 10px; }
  .page-heading-actions > *, .contract-plan-heading-actions > * { flex: 1 1 140px; }
  .app-body .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .app-body .stat-card { min-height: 124px; padding: 15px 13px; }
  .app-body .stat-head { font-size: 15px; gap: 6px; line-height: 1.4; }
  .app-body .stat-icon { display: none; }
  .app-body .stat-card h3 { font-size: clamp(23px, 7vw, 32px); line-height: 1.3; overflow-wrap: anywhere; }
  .app-body .stat-meta { font-size: 14px; line-height: 1.5; flex-wrap: wrap; }
  .app-body .card { border-radius: 16px; }
  .app-body .card-head, .app-body .card-body, .app-body .form-card .card-body { padding: 18px 16px; }
  .app-body .card-head h2 { font-size: 20px; line-height: 1.45; overflow-wrap: anywhere; }
  .app-body .card-head p, .app-body .secondary-cell { font-size: 15px; line-height: 1.65; }
  .app-body .card-head > .toolbar-right, .app-body .card-head > form { width: 100%; }
  .app-body .toolbar, .app-body .toolbar-left, .app-body .toolbar-right { width: 100%; align-items: stretch; }
  .app-body .toolbar-left > *, .app-body .toolbar-right > * { flex: 1 1 150px; }
  .toolbar form select, .app-body .search-box, .app-body .search-box input, .issue-filter select { width: 100%; }
  .app-body .form-grid, .app-body .employee-form-grid, .app-body .equipment-form-preview,
  .app-body .inquiry-fields, .app-body .repair-fields, .app-body .parameter-grid,
  .app-body .role-select-grid, .app-body .permission-select-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .app-body .form-grid > *, .app-body .form-grid .full { min-width: 0; grid-column: 1 / -1; }
  .app-body .form-grid label { font-size: 16px; }
  .app-body .form-grid input, .app-body .form-grid select, .app-body .form-grid textarea { width: 100%; margin-top: 0; }
  .app-body .form-grid textarea { min-height: 140px; line-height: 1.65; }
  .app-body .form-grid input[type=checkbox], .app-body .form-grid input[type=radio] { width: 20px; }
  .app-body .form-actions { flex-wrap: wrap; gap: 10px; }
  .app-body .form-actions > * { flex: 1 1 120px; }
  .app-body .field-hint, .app-body .plain-tip { font-size: 15px; line-height: 1.65; }
  .app-body .plain-tip { margin: 0 16px 18px; padding: 14px; }
  .app-body .data-table.mobile-records { display: block; width: 100%; min-width: 0; border: 0; }
  .mobile-records thead { position: absolute; width: 1px; height: 1px; margin: -1px; clip-path: inset(50%); overflow: hidden; }
  .mobile-records tbody { display: grid; gap: 12px; padding: 0 12px 14px; }
  .app-body .mobile-records tr { display: block; min-width: 0; padding: 8px 14px; border: 1px solid #dce4ef; border-radius: 12px; background: #fff; }
  .app-body .mobile-records td { display: grid; grid-template-columns: minmax(72px, 26%) minmax(0, 1fr); gap: 10px; padding: 10px 0; font-size: 16px; line-height: 1.6; white-space: normal; border: 0; border-bottom: 1px solid #eff2f7; text-align: left; overflow-wrap: anywhere; }
  .app-body .mobile-records td:last-child { border-bottom: 0; }
  .app-body .mobile-records td:only-child { display: block; }
  .mobile-record-label { display: block; font-size: 14px; font-weight: 600; color: #61718a; padding-top: 2px; }
  .app-body .mobile-records .primary-cell { font-size: 17px; line-height: 1.55; }
  .app-body .mobile-records .detail-title { align-items: flex-start; }
  .mobile-records .detail-title > div { min-width: 0; }
  .app-body .mobile-records .table-actions { flex-wrap: wrap; gap: 8px; }
  .app-body .mobile-records .table-actions > * { flex: 1 1 70px; }
  .app-body .mobile-records .inline-form .button { width: 100%; }
  .app-body .mobile-records .delivery-note, .app-body .mobile-records .repair-symptom { max-width: none; }
  .app-body .equipment-cards, .app-body .contract-cards, .app-body .production-contract-grid,
  .app-body .contract-health-grid, .app-body .spec-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .app-body .equipment-card, .app-body .contract-card { padding: 18px 16px; min-width: 0; }
  .equipment-card-top, .equipment-card-foot, .contract-card-top, .contract-card-foot { flex-wrap: wrap; gap: 10px; }
  .app-body .equipment-card h2 { font-size: 21px; line-height: 1.5; }
  .app-body .equipment-type, .app-body .equipment-card > p, .app-body .equipment-card-foot, .app-body .equipment-spec-list span { font-size: 15px; line-height: 1.6; }
  .app-body .equipment-spec-list strong { font-size: 16px; line-height: 1.6; }
  .app-body .equipment-card-foot a { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; }
  .app-body .equipment-module { flex: 0 0 auto; font-size: 14px; line-height: 1.5; white-space: nowrap; }
  .app-body .step-pill, .app-body .badge { font-size: 14px; line-height: 1.5; white-space: normal; }
  .app-body .equipment-spec-list > div { gap: 10px; align-items: start; }
  .equipment-spec-list strong { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .app-body .equipment-module-strip { max-width: 100%; overflow-x: auto; }
  .app-body .issue-record-head { gap: 12px; }
  .app-body .issue-record-list { padding: 0 14px 18px; }
  .app-body .issue-record { padding: 16px; }
  .app-body .issue-record h3 { font-size: 21px; }
  .app-body .issue-record-meta, .app-body .issue-record-details { grid-template-columns: minmax(0, 1fr); }
  .app-body .issue-record-meta span, .app-body .issue-record-details p,
  .app-body .issue-item small, .app-body .issue-item p { font-size: 16px; line-height: 1.7; }
  .app-body .issue-item { grid-template-columns: 32px minmax(0, 1fr); }
  .app-body .issue-item > span { grid-column: 2; justify-self: start; }
  .app-body .issue-item strong { font-size: 18px; line-height: 1.5; }
  .app-body .service-flow { display: flex; flex-direction: column; gap: 0; padding: 16px; }
  .app-body .service-flow > div { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto auto; justify-items: start; gap: 4px 14px; min-height: 88px; text-align: left; padding: 6px 0 18px; }
  .app-body .service-flow b { grid-row: 1 / 3; width: 44px; height: 44px; z-index: 1; }
  .app-body .service-flow strong { font-size: 17px; padding: 0; }
  .app-body .service-flow small { max-width: none; margin: 0; font-size: 15px; line-height: 1.55; }
  .app-body .service-flow > div:not(:last-child):after { left: 21px; top: 50px; bottom: -6px; right: auto; width: 2px; height: auto; }
  .app-body .service-flow .is-current:before { display: none; }
  .app-body .report-focus-list > div { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; }
  .app-body .report-focus-list strong { font-size: 18px; }
  .app-body .report-focus-list small { font-size: 16px; line-height: 1.65; }
  .app-body .repair-card h3, .app-body .contract-cockpit-card h3 { font-size: 19px; line-height: 1.5; }
  .app-body .repair-card > p, .app-body .repair-result, .app-body .contract-cockpit-card > p,
  .app-body .contract-cockpit-specs, .app-body .contract-progress-head span,
  .app-body .funnel-step small, .app-body .action-list small, .app-body .health-card small,
  .app-body .health-card em, .app-body .contract-step small, .app-body .repair-fields span { font-size: 15px; line-height: 1.65; }
  .app-body .repair-meta, .app-body .repair-code { font-size: 14px; line-height: 1.6; }
  .app-body .contract-step strong, .app-body .repair-fields strong, .app-body .action-list strong { font-size: 16px; line-height: 1.6; }
  .app-body .repair-card-top, .app-body .repair-result, .app-body .contract-cockpit-top { flex-wrap: wrap; gap: 10px; }
  .app-body .contract-cockpit-actions .link-cell { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; }
  .app-body .health-card { padding: 14px; gap: 8px; align-items: flex-start; }
  .app-body .health-card > span { display: none; }
  .app-body .contract-health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .report-focus-list .focus-risk, .report-focus-list .focus-warn, .report-focus-list .focus-info { grid-column: 2; justify-self: start; }
  .app-body .chart-bars { overflow-x: auto; justify-content: space-around; padding: 24px 16px; gap: 12px; }
  .app-body .bar-wrap { min-width: 36px; }
  .app-body .list-copy, .app-body .employee-copy { min-width: 0; overflow-wrap: anywhere; }
  .app-body .game-quest-panel { display: none; }
  .app-body .game-banner { padding: 16px; gap: 12px; }
  .game-banner > div { min-width: 0; }
  .app-body .game-banner strong { font-size: 18px; }
  .app-body .game-banner span { font-size: 15px; line-height: 1.65; }
  .app-body .game-banner-progress { display: none; }
  .app-body .contract-plan-card { display: flex; flex-wrap: wrap; padding: 18px; }
  .app-body .contract-plan-card-main { flex: 1 1 100%; min-width: 0; }
  .app-body .contract-plan-card h2 { font-size: 21px; }
  .app-body .contract-plan-card-progress { width: auto; flex: 1; }
  .app-body .contract-plan-summary, .app-body .contract-map-summary { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .app-body .contract-spec-chips, .app-body .contract-map-specs { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-column: auto; grid-row: auto; }
  .app-body .contract-plan-board-head { flex-direction: column; padding: 18px 16px; }
  .app-body .contract-plan-board-tools { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .app-body .contract-plan-board-tools > form { grid-column: 1 / -1; min-width: 0; }
  .app-body .contract-plan-board-tools .button { width: 100%; min-width: 0; }
  .app-body .contract-spec-chips small, .app-body .contract-plan-summary-title small { font-size: 15px; line-height: 1.6; }
  .app-body .contract-spec-chips b, .app-body .contract-plan-summary-title strong { font-size: 16px; line-height: 1.6; }
  .app-body .contract-map-layout { grid-template-columns: minmax(0, 1fr); padding: 0 12px 12px; }
  .app-body .package-list, .app-body .queue-list { grid-template-columns: minmax(0, 1fr); }
  .app-body .package-queue { max-height: none; }
  .app-body .contract-map-scroll { max-width: 100%; min-width: 0; overflow: auto; max-height: 70dvh; }
  .app-body .contract-map-grid { grid-template-columns: 132px repeat(5, minmax(168px, 1fr)); min-width: 1012px; gap: 8px; }
  .contract-map-grid .employee-lane-label, .contract-map-grid .schedule-corner { position: sticky; left: 0; z-index: 3; background: #f3f6fb; border-right: 1px solid #d6dfeb; }
  .contract-map-grid .schedule-day, .contract-map-grid .schedule-corner { position: sticky; top: 0; z-index: 2; background: #edf3ff; }
  .contract-map-grid .schedule-corner { z-index: 4; }
  .app-body .employee-lane-label { flex-wrap: wrap; gap: 8px; padding: 10px; }
  .employee-lane-label > div { min-width: 0; max-width: 100%; }
  .app-body .employee-lane-label small { white-space: normal; overflow-wrap: anywhere; }
  .app-body .employee-lane-label strong, .app-body .schedule-day strong { font-size: 16px; }
  .app-body .employee-lane-label small, .app-body .schedule-day small { font-size: 14px; line-height: 1.5; }
  .employee-lane-label .presence { display: none; }
  .app-body .mission-card strong { font-size: 17px; line-height: 1.5; }
  .app-body .mission-card small { font-size: 15px; line-height: 1.6; }
  .app-body .mission-type, .app-body .package-queue-head small, .app-body .package-all-done { font-size: 14px; line-height: 1.6; }
  .mobile-map-tabs { display: flex; gap: 8px; margin: 0 12px 14px; padding: 5px; border-radius: 12px; background: #edf1f7; }
  .mobile-map-tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: #52637c; font-size: 16px; }
  .mobile-map-tabs button[aria-pressed=true] { background: #fff; color: #2454a4; font-weight: 700; box-shadow: 0 2px 6px #1e365014; }
  .mobile-map-board[data-mobile-panel=queue] .contract-map-scroll,
  .mobile-map-board[data-mobile-panel=map] .package-queue { display: none; }
  .app-body .schedule-note { padding: 14px; margin: 0 12px 16px; }
  .app-body .schedule-note small { font-size: 15px; line-height: 1.6; }
  .app-body .contract-plan-board.is-fullscreen { height: 100vh; height: 100dvh; max-height: 100dvh; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .app-body .contract-plan-board.is-fullscreen .contract-plan-board-head { padding: 14px; }
  .app-body .contract-plan-board.is-fullscreen .contract-plan-board-head p { display: none; }
  .app-body .contract-plan-board.is-fullscreen .contract-map-layout { display: block; min-height: 0; overflow: auto; padding: 0 12px 12px; }
  .app-body .contract-plan-board.is-fullscreen .package-queue { max-height: none; overflow: visible; }
  .app-body .contract-plan-board.is-fullscreen .contract-map-scroll { height: 100%; min-height: 0; max-height: none; }
  .app-body .contract-plan-board.is-fullscreen .contract-map-grid { grid-template-columns: 132px repeat(5, minmax(168px, 1fr)); min-width: 1012px; }
  .app-body .contract-plan-board.is-fullscreen .schedule-note { display: none; }
  .auth-page { display: block; overflow: auto; min-height: 100vh; min-height: 100dvh; padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
  .auth-page:before, .auth-page:after { display: none; }
  .auth-page .auth-shell { width: 100%; max-width: 480px; margin: 0 auto; min-height: 0; grid-template-columns: minmax(0, 1fr); }
  .auth-page .auth-brand-panel { padding: 22px; }
  .auth-page .auth-brand-panel .brand-mark { margin-bottom: 16px; }
  .auth-page .auth-brand-panel h1 { font-size: 27px; margin-bottom: 0; }
  .auth-page .auth-brand-panel .eyebrow, .auth-page .auth-brand-panel p, .auth-page .brand-lines { display: none; }
  .auth-page .auth-card, .auth-page .setup-shell .auth-card { padding: 24px 20px; }
  .auth-page .auth-card-head h2 { font-size: 25px; }
  .auth-page .auth-card-head p, .auth-page .form-grid label { font-size: 16px; line-height: 1.6; }
  .auth-page .form-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-page .login-options { flex-wrap: wrap; gap: 14px; font-size: 14px; }
  .auth-page .button { min-height: 48px; font-size: 16px; }
  .auth-page .notice, .auth-page .setup-note { overflow-wrap: anywhere; }
}
@media (min-width: 761px) and (max-width: 1023px) {
  .auth-page { overflow: auto; display: block; padding: 28px; }
  .auth-page:before, .auth-page:after { display: none; }
  .auth-page .auth-shell { width: 100%; max-width: 520px; margin: auto; grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .auth-page .auth-brand-panel { padding: 28px; }
  .auth-page .auth-brand-panel .brand-mark { margin-bottom: 18px; }
  .auth-page .auth-brand-panel p, .auth-page .brand-lines { display: none; }
  .auth-page .auth-card { padding: 28px; }
}
@media (prefers-reduced-motion: reduce) { .app-body .sidebar { transition: none; } }
@media print { .mobile-nav, .sidebar-backdrop, .mobile-map-tabs { display: none !important; } }
