/* MERQIVA mobile presentation layer — UI only, no workflow or data changes. */
@media (max-width: 900px) {
  :root {
    --mobile-ink: #111317;
    --mobile-muted: #69717b;
    --mobile-surface: #ffffff;
    --mobile-page: #f3f2ee;
    --mobile-line: #dedfdc;
    --mobile-dark: #101317;
    --mobile-accent: #d5342e;
  }

  html, body {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: clip;
    background: var(--mobile-page);
    color: var(--mobile-ink);
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-x: none;
  }

  body, button, input, select, textarea {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  }

  .app-shell, .app-main, .app-main > *, .content-panel,
  .tp-page, .tools-page, .exec-page, .intake-shell, .sx-page,
  .ops-section, .history-panel, .batch-create {
    width: 100%;
    max-width: 100% !important;
    min-width: 0;
  }

  .app-main {
    padding: calc(68px + env(safe-area-inset-top)) 12px calc(28px + env(safe-area-inset-bottom)) !important;
    overflow-x: clip;
  }

  .mobile-menu-toggle {
    top: calc(10px + env(safe-area-inset-top));
    left: 12px;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 13px;
    background: var(--mobile-dark);
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
  }

  .mobile-menu-toggle span { font-size: 21px; }
  .mobile-menu-open .mobile-menu-toggle {
    top: calc(10px + env(safe-area-inset-top));
    left: min(calc(88vw - 58px), 264px);
  }

  .app-sidebar.pro-sidebar {
    width: min(88vw, 322px);
    padding: calc(12px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom));
    background: #0d1014;
    border-right: 1px solid #292c30;
  }

  .app-sidebar .pro-brand {
    display: grid !important;
    grid-template-columns: 44px minmax(0,1fr);
    grid-template-rows: auto auto;
    column-gap: 11px !important;
    align-items: center !important;
    min-height: 70px !important;
    padding: 8px 12px 12px !important;
  }

  .app-sidebar .pro-brand::before {
    content: "";
    grid-row: 1 / 3;
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: url('/static/wester-w-app-icon.svg') center/cover no-repeat;
  }

  .app-sidebar .pro-brand .brand-wordmark {
    grid-column: 2;
    align-self: end;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    font-size: 17px !important;
    font-weight: 800 !important;
    letter-spacing: .12em !important;
  }

  .app-sidebar .pro-brand .edition-label {
    grid-column: 2;
    align-self: start;
    margin: 2px 0 0 !important;
    color: #989fa7 !important;
    font-size: 9px !important;
    letter-spacing: .14em !important;
  }

  .app-sidebar .sidebar-nav { padding: 4px 4px 16px; }
  .app-sidebar .sidebar-nav .nav-heading {
    margin: 19px 10px 6px !important;
    color: #7e8790 !important;
    font-size: 9px !important;
  }
  .app-sidebar .nav-item {
    min-height: 46px !important;
    margin: 2px 0;
    padding: 11px 12px !important;
    border-radius: 10px;
    font-size: 14px;
  }
  .app-sidebar .nav-item.active {
    background: #f1eee7 !important;
    color: #111317 !important;
    box-shadow: inset 3px 0 0 var(--mobile-accent);
  }
  .app-sidebar .nav-item.active .nav-icon { color: var(--mobile-accent); }
  .app-sidebar .owner-view-label { border-color: #30343a; background: #171b20; }
  .app-sidebar .owner-view-label span { color: #a8afb7; }

  .table-wrap, .rate-table-wrap, .finance-table-wrap, .range-table-wrap,
  .tp-table-wrap, .sx-money-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  img, svg, video, canvas { max-width: 100%; }
}

@media (max-width: 650px) {
  body { font-size: 14px; line-height: 1.45; }

  h1, .page-header h1, .pro-page-header h1,
  .tp-hero h1, .prep-hero h1, .sx-hero h1, .exec-hero h1,
  .tools-head h1, .intake-hero h1 {
    margin: 0 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    font-size: clamp(24px, 7.2vw, 30px) !important;
    font-weight: 800 !important;
    line-height: 1.08 !important;
    letter-spacing: -.035em !important;
  }

  h2, .panel h2, .task-pane-head h2 { font-size: 19px; line-height: 1.2; }
  h3 { font-size: 16px; line-height: 1.25; }

  .page-header, .pro-page-header, .module-header,
  .tp-hero, .prep-hero, .sx-hero, .exec-hero, .tools-head, .intake-hero {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    margin: 0 0 12px !important;
    padding: 18px 16px !important;
    border: 0 !important;
    border-radius: 15px !important;
    background: var(--mobile-dark) !important;
    color: #fff !important;
    box-shadow: none !important;
  }

  .page-header h1, .pro-page-header h1, .module-header h1,
  .tp-hero h1, .prep-hero h1, .sx-hero h1, .exec-hero h1,
  .tools-head h1, .intake-hero h1 { color: #fff !important; }

  .eyebrow, .exec-eyebrow, .sx-eyebrow,
  .tp-hero .eyebrow, .prep-hero .eyebrow {
    margin-bottom: 7px !important;
    color: #aeb5bc !important;
    font-size: 9px !important;
    letter-spacing: .14em !important;
  }

  .prep-hero-mark, .sx-route { display: none !important; }
  .exec-hero-date { width: 100%; margin-top: 12px; text-align: left !important; }
  .exec-hero-date span { color: #aeb5bc !important; }

  .panel, .card, .module, .dashboard-section, .content-panel,
  .tp-panel, .exec-panel, .sx-section, .tool-group,
  .batch-create, .task-layout, .operation-control, .history-panel {
    min-width: 0;
    border: 1px solid var(--mobile-line) !important;
    border-radius: 13px !important;
    background: var(--mobile-surface) !important;
    box-shadow: none !important;
  }

  .panel, .dashboard-section, .content-panel,
  .tp-panel, .exec-panel, .sx-section, .tool-group { padding: 15px !important; }

  .cards, .pro-kpi-grid, .exec-kpis, .exec-finance,
  .work-kpis, .match-grid, .operation-alerts {
    gap: 9px !important;
  }

  button, .button, .premium-button, input, select, textarea {
    min-height: 46px;
    border-radius: 10px !important;
    font-size: 16px;
  }

  button, .button, .premium-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 14px;
    background: var(--mobile-dark);
    color: #fff;
    font-size: 14px;
    font-weight: 750;
    box-shadow: none !important;
  }

  .secondary, .button.secondary, .ghost, .link-button {
    border: 1px solid #d9dde0 !important;
    background: #eef0f1 !important;
    color: var(--mobile-ink) !important;
  }

  input, select, textarea {
    width: 100%;
    max-width: 100%;
    padding: 11px 12px;
    border: 1px solid #cfd3d6;
    background: #fff;
    color: var(--mobile-ink);
  }

  input:focus, select:focus, textarea:focus {
    border-color: #737b84;
    outline: 3px solid rgba(17,19,23,.08);
  }

  .batch-form, .sx-form, .tp-grid, .tp-grid.three, .tp-builder,
  .packing-form, .production-form, .workflow-form,
  .filter-form, .datebar, .action-form, .report-toolbar-inline {
    grid-template-columns: 1fr !important;
  }

  .batch-form button, .sx-form .wide, .tp-field.full,
  .packing-form .file-control, .production-form .file-control { grid-column: auto !important; }

  .tp-steps { grid-template-columns: 1fr 1fr !important; gap: 7px; }
  .tp-step { min-height: 48px; padding: 11px !important; }
  .tp-product-grid { grid-template-columns: 1fr 1fr !important; gap: 7px; }
  .tp-product-card { padding: 8px; }

  .tools-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .tool-list { grid-template-columns: 1fr !important; }
  .tools-primary { gap: 10px; }

  .task-layout { overflow: hidden; }
  .task-roadmap-head { padding: 13px 14px !important; background: var(--mobile-dark) !important; }
  .task-roadmap-list { grid-template-columns: 1fr 1fr !important; }
  .task-nav-button { min-height: 58px; padding: 8px 9px !important; border-radius: 0 !important; font-size: 12px; }
  .task-nav-button.active { background: #fff !important; color: var(--mobile-ink) !important; box-shadow: inset 3px 0 var(--mobile-accent) !important; }
  .task-content { padding: 13px 11px !important; }
  .task-instruction { width: 100%; white-space: normal; }

  .operation-flow { grid-template-columns: 1fr 1fr !important; gap: 7px; }
  .operation-step { min-width: 0 !important; padding: 10px !important; }
  .operation-step::after { display: none !important; }

  .mobile-picking-card { border-radius: 12px !important; box-shadow: none !important; }
  .mobile-picking-top { grid-template-columns: 34px 58px minmax(0,1fr) !important; gap: 9px !important; }
  .mobile-picking-top .picking-image img { width: 58px !important; height: 58px !important; }
  .mobile-picking-name b { font-size: 15px !important; }

  .tabs, .prep-tabs, .work-tabs {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 7px;
  }
  .tab, .prep-tab, .work-tab { width: 100%; min-height: 44px; }

  .table-wrap { border-radius: 11px !important; }
  table:not(.mobile-card-table) { font-size: 12px; }
  th, td { padding: 9px 10px; }

  .tp-actions {
    bottom: calc(8px + env(safe-area-inset-bottom));
    padding: 10px !important;
    border-radius: 12px !important;
  }

  .tp-actions p { display: none; }
  .tp-actions button { width: 100%; }

  .alert, .warning-panel, .scope-note, .operation-mode-note {
    border-radius: 10px !important;
    font-size: 12px;
    line-height: 1.45;
  }
}

@media (max-width: 390px) {
  .app-main { padding-left: 9px !important; padding-right: 9px !important; }
  .tp-product-grid, .task-roadmap-list, .operation-flow,
  .tabs, .prep-tabs, .work-tabs { grid-template-columns: 1fr !important; }
}
