/* Mobile workspace layout and shared order-action dialogs.
   Order detail deliberately has no data-sc-mobile-page marker. */
.sc-date-mobile { display: none; }
.sc-mobile-create-fab { display: none; }
.sc-mobile-orders-heading, .sc-mobile-pending-heading, .sc-mobile-fabric-tracking { display: none; }

@media (max-width: 767px) {
  [data-sc-mobile-page="overview"] > [data-sc-overview-desktop-only] { display: none !important; }
  [data-sc-mobile-page] .rounded-xl.shadow-sm { border-radius: 14px; }

  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"],
  [data-sc-mobile-page="orders"] [data-sc-date-row] {
    align-items: stretch !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    overflow: visible !important;
  }

  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] h2,
  [data-sc-mobile-page="orders"] [data-sc-date-row] h3 { flex-basis: 100%; }

  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] select,
  [data-sc-mobile-page="orders"] [data-sc-date-row] select { width: 100%; }

  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 { gap: 10px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 > div { padding: 14px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 .w-12,
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 .h-12 { width: 42px; height: 42px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.lg\:grid-cols-2 > div,
  [data-sc-mobile-page="overview"] > .bg-white { padding: 16px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-2.md\:grid-cols-3.lg\:grid-cols-6 { gap: 8px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-2.md\:grid-cols-3.lg\:grid-cols-6 > div { padding: 10px 6px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-2.md\:grid-cols-3.lg\:grid-cols-6 .text-3xl { font-size: 24px; }
  [data-sc-mobile-page="overview"] .space-y-2 button { align-items: flex-start; gap: 10px; }
  [data-sc-mobile-page="overview"] .space-y-2 button span { text-align: right; }

  [data-sc-mobile-page="orders"] > .bg-white:first-child { padding: 12px; }
  [data-sc-mobile-page="orders"] > .bg-white:first-child > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  [data-sc-mobile-page="orders"] > .bg-white:first-child > div > :first-child,
  [data-sc-mobile-page="orders"] > .bg-white:first-child > div > button {
    grid-column: 1 / -1;
  }

  [data-sc-mobile-page="orders"] > .bg-white:first-child select,
  [data-sc-mobile-page="orders"] > .bg-white:first-child label { min-width: 0; width: 100%; }
  [data-sc-mobile-page="orders"] > .bg-white:first-child label select { width: 100%; margin-top: 4px; }
  /* Order tables become field-labelled cards. There is no horizontal scroll. */
  [data-sc-mobile-page="orders"] .overflow-x-auto { overflow: visible; }
  [data-sc-mobile-page="orders"] table,
  [data-sc-mobile-page="orders"] tbody,
  [data-sc-mobile-page="orders"] tr,
  [data-sc-mobile-page="orders"] td { display: block; width: 100%; }
  [data-sc-mobile-page="orders"] table { min-width: 0; }
  [data-sc-mobile-page="orders"] table thead { display: none; }
  [data-sc-mobile-page="orders"] table tbody { padding: 10px; }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) {
    position: relative;
    margin: 0 0 12px;
    padding: 13px 14px 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
  }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) > td {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 12px;
    padding: 9px 0;
    color: #111827;
    border-bottom: 1px solid #f0f1f3;
    text-align: right;
    align-items: center;
  }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) > td::before {
    color: #6b7280;
    font-size: 13px;
    text-align: left;
  }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(1),
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(2) { display: none; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(3) {
    display: block;
    padding: 3px 0 12px;
    color: #b7791f;
    font-size: 17px;
    font-weight: 700;
    text-align: left;
  }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(3)::before { content: none; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(4)::before { content: "窗帘类型"; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(5)::before { content: "数量"; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(6)::before { content: "生产尺寸"; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(7)::before { content: "加工进度"; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(8)::before { content: "交产时间"; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(9)::before { content: "状态"; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) {
    display: flex;
    flex-wrap: wrap;
    grid-template-columns: none;
    gap: 8px;
    padding: 13px 0 3px;
    border-bottom: 0;
    justify-content: flex-end;
  }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10)::before { content: none; }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) > td > div { justify-content: flex-end; }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) button[title] {
    display: inline-flex;
    min-height: 34px;
    padding: 7px 10px;
    color: #374151;
    background: #f3f4f6;
    border-radius: 8px;
    align-items: center;
    gap: 4px;
  }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) button[title]::after {
    font-size: 12px;
    content: attr(title);
  }
  [data-sc-mobile-page="orders"] table tbody > tr:has(td[colspan]) { margin: -20px 12px 12px; }
  [data-sc-mobile-page="orders"] table tbody > tr:has(td[colspan]) td {
    padding: 22px 14px 14px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-top: 0;
    border-radius: 0 0 14px 14px;
  }
  [data-sc-mobile-page="orders"] .flex.items-center.justify-between.px-4.py-2 {
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
    padding: 12px;
  }
  [data-sc-mobile-page="orders"] .flex.items-center.justify-between.px-4.py-2 > div:first-child {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
  }
  [data-sc-mobile-page="orders"] .flex.items-center.justify-between.px-4.py-2 > div:first-child > :first-child { justify-self: start; text-align: left; }
  [data-sc-mobile-page="orders"] .flex.items-center.justify-between.px-4.py-2 > div:first-child > select { justify-self: center; width: auto; }
  [data-sc-mobile-page="orders"] .flex.items-center.justify-between.px-4.py-2 > div:first-child > :last-child { justify-self: end; text-align: right; white-space: nowrap; }
  [data-sc-mobile-page="orders"] .flex.items-center.justify-between.px-4.py-2 > div:last-child {
    width: 100%;
    justify-content: space-between;
  }

  /* Date filters use a single compact trigger; choices live in a bottom sheet. */
  [data-sc-date-filter] .sc-date-desktop { display: none !important; }
  [data-sc-date-filter] .sc-date-mobile { display: block; width: 100%; }
  [data-sc-date-filter] .sc-date-picker-trigger {
    display: flex;
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    color: #374151;
    text-align: left;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    align-items: center;
    justify-content: space-between;
  }
  [data-sc-date-filter] .sc-date-picker-trigger span { font-size: 13px; color: #6b7280; }
  [data-sc-date-filter] .sc-date-picker-trigger strong { color: #1d4ed8; font-size: 14px; }
  .sc-date-sheet-backdrop {
    position: fixed;
    z-index: 60;
    inset: 0;
    display: flex;
    padding: 16px;
    background: rgba(15, 23, 42, .42);
    align-items: flex-end;
  }
  .sc-date-sheet {
    width: 100%;
    max-width: 520px;
    padding: 18px;
    margin: 0 auto;
    background: #fff;
    border-radius: 18px 18px 12px 12px;
    box-shadow: 0 -10px 36px rgba(15, 23, 42, .2);
  }
  .sc-date-sheet-header { display: flex; margin-bottom: 16px; align-items: center; justify-content: space-between; }
  .sc-date-sheet-header h4 { margin: 0; color: #111827; font-size: 17px; font-weight: 700; }
  .sc-date-sheet-header button { width: 32px; height: 32px; color: #6b7280; font-size: 26px; line-height: 1; background: #f3f4f6; border-radius: 50%; }
  .sc-date-preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
  .sc-date-preset-grid button { min-height: 42px; color: #374151; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 9px; }
  .sc-date-preset-grid button.is-active { color: #1d4ed8; background: #dbeafe; border-color: #93c5fd; font-weight: 700; }
  .sc-date-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 16px; margin-top: 16px; border-top: 1px solid #e5e7eb; }
  .sc-date-custom label { display: grid; gap: 6px; color: #6b7280; font-size: 12px; }
  .sc-date-custom input { min-width: 0; min-height: 42px; padding: 7px; color: #111827; background: #fff; border: 1px solid #d1d5db; border-radius: 9px; }
  .sc-date-error { margin: 10px 0 0; color: #dc2626; font-size: 13px; }
  .sc-date-sheet-done { width: 100%; min-height: 44px; margin-top: 16px; color: #fff; background: #2563eb; border-radius: 10px; font-weight: 700; }

  /* Compact operational density: more records per screen, without shrinking tap targets. */
  #root > .min-h-screen > main { padding: 8px 8px calc(60px + env(safe-area-inset-bottom, 0px)); }
  #root > .min-h-screen > main .mb-6 { margin-bottom: 10px; }
  #root > .min-h-screen > main .mt-6 { margin-top: 10px; }
  #root > .min-h-screen > main .p-6 { padding: 14px; }
  #root > .min-h-screen > main .p-5 { padding: 12px; }
  #root > .min-h-screen > main .p-4 { padding: 11px; }
  #root > .min-h-screen > main .gap-6 { gap: 12px; }
  #root > .min-h-screen > main .gap-4 { gap: 10px; }
  #root > .min-h-screen > main h2 { font-size: 20px; line-height: 28px; }
  #root > .min-h-screen > main h3 { font-size: 16px; line-height: 22px; }
  #root > .min-h-screen > main input:not([type="checkbox"]):not([type="radio"]),
  #root > .min-h-screen > main select { min-height: 38px; }

  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 { gap: 8px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 > div { padding: 10px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 .w-12,
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 .h-12 { width: 36px; height: 36px; }
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 .text-2xl { font-size: 21px; line-height: 24px; }
  [data-sc-mobile-page="overview"] .space-y-3 > * + * { margin-top: 7px; }
  [data-sc-mobile-page="overview"] .space-y-2 > * + * { margin-top: 6px; }
  [data-sc-mobile-page="overview"] .space-y-2 button { padding: 9px 10px; }

  [data-sc-mobile-page="orders"] > .bg-white:first-child { padding: 10px; }
  [data-sc-mobile-page="orders"] > .bg-white:first-child > div { gap: 8px; }
  [data-sc-mobile-page="orders"] table tbody { padding: 8px; }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) {
    margin-bottom: 8px;
    padding: 10px 11px 6px;
    border-radius: 11px;
  }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) > td {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    padding: 6px 0;
    font-size: 14px;
  }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) > td::before { font-size: 12px; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(3) { padding-bottom: 8px; font-size: 16px; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) { gap: 6px; padding-top: 9px; }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) button[title] { min-height: 32px; padding: 6px 8px; }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) button[title]::after { font-size: 11px; }

  .sc-date-sheet { padding: 14px; }
  .sc-date-sheet-header { margin-bottom: 11px; }
  .sc-date-preset-grid { gap: 7px; }
  .sc-date-preset-grid button { min-height: 38px; font-size: 13px; }
  .sc-date-custom { padding-top: 11px; margin-top: 11px; }
  .sc-date-sheet-done { min-height: 40px; margin-top: 12px; }

  /* Mobile shell: no desktop header strip, only the task-focused bottom tabs. */
  #root > .min-h-screen > header > div > div > div:first-child,
  #root > .min-h-screen > header > div > div > div:last-child { display: none; }
  #root > .min-h-screen > header nav button[data-sc-nav-id="settings"] { display: none; }

  /* Keep the complete header tree at the bottom so fixed tabs are never clipped. */
  #root > .min-h-screen > header {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    height: calc(48px + env(safe-area-inset-bottom, 0px));
    min-height: 48px;
    box-sizing: border-box;
    overflow: visible;
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 18px rgba(15, 23, 42, .08);
  }
  #root > .min-h-screen > header > div {
    display: flex;
    height: 100%;
    min-height: 0;
    padding: 0 6px env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
    overflow: visible;
  }
  #root > .min-h-screen > header > div > div {
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 100%;
  }
  #root > .min-h-screen > header nav {
    position: static;
    display: flex;
    flex: 1 1 0;
    width: 100%;
    height: 100%;
    min-width: 0;
    padding: 0;
    gap: 0;
    justify-content: stretch;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  #root > .min-h-screen > header nav button:not([data-sc-nav-id="settings"]) {
    display: flex;
    flex: 1 1 0;
    flex-direction: row;
    width: 0;
    min-width: 0;
    max-width: none;
    height: 100%;
    gap: 5px;
    padding: 0 2px;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
    align-items: center;
    justify-content: center;
  }
  #root > .min-h-screen > header nav button svg { display: block; flex: 0 0 17px; width: 17px; height: 17px; }
  #root > .min-h-screen > header nav button[data-sc-nav-id="logout"] {
    flex: 0 0 12.5%;
    width: 12.5%;
    max-width: 12.5%;
    padding: 0;
  }

  /* The overview title, date filter and factory selector are one operational row. */
  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] {
    flex-wrap: nowrap !important;
    gap: 6px !important;
    align-items: center !important;
  }
  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] h2 {
    flex: 0 0 auto;
    margin: 0;
    font-size: 19px;
    white-space: nowrap;
  }
  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] [data-sc-date-filter] { width: auto; flex: 0 0 auto; }
  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] [data-sc-date-filter] .sc-date-mobile { width: auto; }
  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] .sc-date-picker-trigger { width: auto; min-height: 36px; padding: 7px 9px; }
  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] .sc-date-picker-trigger span { display: none; }
  [data-sc-mobile-page="overview"] [data-sc-date-row="overview"] select {
    flex: 1 1 0;
    width: auto !important;
    min-width: 0;
    min-height: 36px;
    padding: 6px 8px;
  }
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-sc-mobile-page="overview"] .grid.grid-cols-1.md\:grid-cols-5 > div { min-width: 0; }

  /* Order search/filter become two purposeful entry points, with confirmation in the sheet. */
  [data-sc-mobile-page="orders"] > [data-sc-desktop-order-filters] { display: none; }
  .sc-mobile-filter-backdrop {
    position: fixed;
    z-index: 61;
    inset: 0;
    display: flex;
    padding: 16px;
    background: rgba(15, 23, 42, .42);
    align-items: flex-end;
  }
  .sc-mobile-filter-sheet {
    display: grid;
    width: 100%;
    min-width: 0;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    gap: 12px;
    padding: 15px;
    margin: 0 auto;
    background: #fff;
    border-radius: 18px 18px 12px 12px;
  }
  .sc-mobile-filter-sheet-header { display: flex; align-items: center; justify-content: space-between; }
  .sc-mobile-filter-sheet-header h3 { margin: 0; font-size: 17px; }
  .sc-mobile-filter-sheet-header button { width: 30px; height: 30px; color: #6b7280; font-size: 24px; line-height: 1; background: #f3f4f6; border-radius: 50%; }
  .sc-mobile-filter-sheet > input,
  .sc-mobile-filter-sheet > label select,
  .sc-mobile-filter-sheet > label input,
  .sc-mobile-filter-dates input { width: 100%; min-width: 0; max-width: 100%; min-height: 42px; padding: 8px 10px; box-sizing: border-box; background: #fff; border: 1px solid #d1d5db; border-radius: 9px; font-size: 16px; }
  .sc-mobile-filter-sheet > label,
  .sc-mobile-filter-dates > label { display: grid; min-width: 0; gap: 5px; color: #4b5563; font-size: 13px; font-weight: 600; }
  .sc-mobile-filter-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .sc-mobile-filter-error { margin: 0; color: #dc2626; font-size: 12px; line-height: 18px; }
  .sc-mobile-filter-confirm { width: 100%; min-height: 42px; color: #fff; background: #2563eb; border-radius: 9px; font-weight: 700; }
  .sc-mobile-filter-confirm:disabled { opacity: .5; cursor: not-allowed; }

  /* Orders: one compact control row, followed by full-width cards. */
  [data-sc-mobile-page="orders"] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
  }
  [data-sc-mobile-page="orders"] > .sc-mobile-orders-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 7px;
  }
  [data-sc-mobile-page="orders"] .sc-mobile-order-tabs {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    gap: 3px;
    padding: 3px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
  }
  [data-sc-mobile-page="orders"] .sc-mobile-order-tab {
    display: inline-flex;
    flex: 1 1 0;
    min-width: 0;
    min-height: 32px;
    padding: 5px 4px;
    gap: 4px;
    align-items: center;
    justify-content: center;
    color: #64748b;
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    white-space: nowrap;
  }
  [data-sc-mobile-page="orders"] .sc-mobile-order-tab[aria-selected="true"] {
    color: #1d4ed8;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
  }
  [data-sc-mobile-page="orders"] .sc-mobile-order-count {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 500;
    line-height: 16px;
  }
  [data-sc-mobile-page="orders"] .sc-mobile-search-button,
  [data-sc-mobile-page="orders"] .sc-mobile-filter-icon {
    display: inline-flex;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    padding: 0;
    align-items: center;
    justify-content: center;
    color: #2563eb;
    background: #fff;
    border: 1px solid #dbeafe;
    border-radius: 8px;
  }
  [data-sc-mobile-page="orders"] .sc-mobile-search-button svg { display: block; width: 16px; height: 16px; }
  .sc-mobile-create-fab {
    position: fixed;
    z-index: 45;
    right: 14px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    width: 52px;
    height: 52px;
    padding: 5px;
    gap: 0;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: #16a34a;
    border: 1px solid #15803d;
    border-radius: 50%;
    box-shadow: 0 3px 12px rgba(22, 101, 52, .3);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    cursor: grab;
  }
  .sc-mobile-create-fab svg { display: block; flex: 0 0 22px; width: 22px; height: 22px; }
  .sc-mobile-create-fab span { font-size: 10px; font-weight: 600; line-height: 12px; }
  .sc-mobile-create-fab.is-dragging { cursor: grabbing; transition: none; }
  .sc-mobile-create-fab:focus-visible { outline: 3px solid #86efac; outline-offset: 3px; }
  [data-sc-mobile-page="orders"] [data-sc-date-row="pending"],
  [data-sc-mobile-page="orders"] [data-sc-date-row="completed"] { display: none !important; }
  [data-sc-mobile-page="orders"][data-sc-active-order-tab="pending"] [data-sc-order-panel="completed"],
  [data-sc-mobile-page="orders"][data-sc-active-order-tab="completed"] [data-sc-order-panel="pending"] { display: none !important; }
  [data-sc-mobile-page="orders"] .overflow-x-auto,
  [data-sc-mobile-page="orders"] table,
  [data-sc-mobile-page="orders"] tbody,
  [data-sc-mobile-page="orders"] tr,
  [data-sc-mobile-page="orders"] td {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
  }
  [data-sc-mobile-page="orders"] table tbody > tr:not(:has(td[colspan])) > td { overflow-wrap: anywhere; }
  [data-sc-mobile-page="orders"] table tbody > tr:has(td[colspan]) {
    width: auto;
    margin: 0 0 8px;
  }
  [data-sc-mobile-page="orders"] .sc-mobile-fabric-tracking {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    padding-top: 6px;
    margin-top: 6px;
    color: #374151;
    border-top: 1px solid #f0f1f3;
    font-size: 12px;
    font-weight: 400;
    line-height: 18px;
  }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(6) { row-gap: 0; }
  [data-sc-mobile-page="orders"] .sc-mobile-fabric-tracking span { color: #6b7280; text-align: left; }
  [data-sc-mobile-page="orders"] .sc-mobile-fabric-tracking strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 600;
    text-align: right;
  }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(9) > span {
    justify-self: end;
    width: max-content;
    max-width: 100%;
  }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) { justify-content: flex-end; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) > div {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end !important;
  }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) button[title] {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 32px;
    padding: 5px;
    gap: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    align-items: center;
    justify-content: center;
  }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) button[hidden] { display: none !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) button[title="打印"],
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) button[title="编辑订单"] { display: none !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) button svg { display: none; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] td:nth-child(10) button[title]::after { font-size: 12px; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="编辑订单"]::after { content: "编辑" !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="查看详情"]::after { content: "详情" !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="暂搁置"]::after { content: "搁置" !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="恢复处理"]::after { content: "恢复" !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="打印"] { color: #1d4ed8 !important; background: #dbeafe !important; border-color: #bfdbfe !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="编辑订单"] { color: #4338ca !important; background: #e0e7ff !important; border-color: #c7d2fe !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="查看详情"] { color: #334155 !important; background: #e2e8f0 !important; border-color: #cbd5e1 !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="备注"] { color: #92400e !important; background: #fef3c7 !important; border-color: #fde68a !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="暂搁置"] { color: #9a3412 !important; background: #ffedd5 !important; border-color: #fed7aa !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="恢复处理"] { color: #166534 !important; background: #dcfce7 !important; border-color: #bbf7d0 !important; }
  [data-sc-mobile-page="orders"] table[data-sc-order-table] button[title="删除"] { color: #b91c1c !important; background: #fee2e2 !important; border-color: #fecaca !important; }

  /* New orders use compact label/value rows on phones. */
  #root > .min-h-screen > main [data-sc-order-form="create"] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] > [data-sc-order-form-heading] {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] [data-sc-order-form-heading] > button {
    display: inline-flex;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 10px;
    align-items: center;
    justify-content: center;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] [data-sc-order-form-heading] > h2 { margin: 0; font-size: 16px; line-height: 24px; }
  #root > .min-h-screen > main [data-sc-order-form="create"] > form {
    min-width: 0;
    padding: 6px 12px 12px;
    border-radius: 14px;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] form .grid.grid-cols-2 {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] form .grid.grid-cols-2 > div { min-width: 0; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form .grid.grid-cols-2 > div:empty { display: none; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form .mb-4 { margin-bottom: 0; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form .-mt-2 { margin-top: 0; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form div:has(> label.block) {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
    min-height: 54px;
    padding: 5px 0;
    border-bottom: 1px solid #eef0f3;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] form label { margin: 0; font-size: 14px; line-height: 20px; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form label.block { color: #475569; font-weight: 400; white-space: nowrap; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form div:has(> label.block) > :not(label.block) { grid-column: 2; min-width: 0; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form div:has(> label.block) > p { margin: 0 0 3px; text-align: right; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input:not([type="checkbox"]):not([type="radio"]),
  #root > .min-h-screen > main [data-sc-order-form="create"] form select {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 8px 4px;
    box-sizing: border-box;
    font-size: 16px;
    line-height: 24px;
    text-align: right;
    border-radius: 6px;
    background-color: transparent;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input:not(.border-red-500):not([type="checkbox"]):not([type="radio"]),
  #root > .min-h-screen > main [data-sc-order-form="create"] form select:not(.border-red-500) { border-color: transparent; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input::placeholder { color: #94a3b8; font-size: 14px; opacity: 1; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input:disabled { color: #94a3b8; -webkit-text-fill-color: #94a3b8; opacity: 1; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input:not([type="checkbox"]):not([type="radio"]):focus,
  #root > .min-h-screen > main [data-sc-order-form="create"] form select:focus {
    background-color: #f0f6ff;
    border-color: #93c5fd;
    outline: none;
    box-shadow: 0 0 0 1px #bfdbfe;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] form select { text-align-last: right; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input[type="number"] { appearance: textfield; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input::-webkit-inner-spin-button,
  #root > .min-h-screen > main [data-sc-order-form="create"] form input::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form > div.mb-4:has(> input) {
    margin-left: 112px;
    padding: 4px 0 8px;
    border-bottom: 1px solid #eef0f3;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input[type="date"] { min-inline-size: 0; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input[type="date"]::-webkit-date-and-time-value { text-align: right; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form label:has(input[type="checkbox"]),
  #root > .min-h-screen > main [data-sc-order-form="create"] form label:has(input[type="radio"]) {
    display: flex;
    min-height: 36px;
    margin: 0;
    padding: 6px 0;
    gap: 8px;
    align-items: center;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] form div:has(> label.block) > label:has(input[type="checkbox"]) { justify-content: flex-end; font-size: 12px; white-space: nowrap; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form .grid > div:has(> label > input[type="checkbox"]):not(:has(> label.block)) {
    padding: 5px 0;
    border-bottom: 1px solid #eef0f3;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] form .grid > div > label:has(> input[type="checkbox"]):has(> span) { flex-direction: row-reverse; justify-content: space-between; min-height: 44px; padding: 0 4px 0 0; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form .grid > div > label:has(> input[type="checkbox"]) > span { color: #475569; }
  #root > .min-h-screen > main [data-sc-order-form="create"] form input[type="checkbox"],
  #root > .min-h-screen > main [data-sc-order-form="create"] form input[type="radio"] {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin: 0;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] [data-sc-order-form-actions] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding-top: 14px;
    border-top: 0;
  }
  #root > .min-h-screen > main [data-sc-order-form="create"] [data-sc-order-form-actions] > button {
    display: inline-flex;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 12px;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 24px;
  }

  /* Detail header: equal side columns keep the order number truly centered. */
  [data-sc-detail-header] { display: block; padding: 10px 12px; }
  [data-sc-detail-header] > :not([data-sc-detail-heading]) { display: none; }
  [data-sc-detail-heading] {
    display: grid;
    grid-template-columns: minmax(76px, 1fr) minmax(0, 1.5fr) minmax(76px, 1fr);
    width: 100%;
    min-width: 0;
    gap: 4px;
    align-items: center;
  }
  [data-sc-detail-heading] > h1 {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    justify-self: start;
    white-space: nowrap;
    font-size: 14px;
  }
  [data-sc-detail-heading] > span {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    width: 100%;
    overflow-wrap: anywhere;
    text-align: center;
    font-size: 13px;
  }
  [data-sc-detail-heading] > button {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    padding: 6px 8px;
    white-space: nowrap;
    font-size: 13px;
  }

  .sc-date-sheet, .sc-mobile-filter-sheet { position: relative; }
  .sc-date-sheet-header, .sc-mobile-filter-sheet-header { padding-right: 28px; }
  .sc-date-sheet-header > button, .sc-mobile-filter-sheet-header > button {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex: none;
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
  }
}

/* Portal dialogs use dedicated classes on both desktop and mobile. */
.sc-order-action-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(15, 23, 42, .45);
}
.sc-order-action-dialog {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 20px;
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  color: #111827;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .24);
  font-size: 14px;
  line-height: 22px;
}
.sc-order-action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sc-order-action-header h3 { margin: 0; font-size: 18px; font-weight: 700; line-height: 26px; }
.sc-order-action-header > button {
  display: inline-flex;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  background: #f3f4f6;
  border: 0;
  border-radius: 9px;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}
.sc-order-action-order {
  margin: 0 0 12px;
  padding: 8px 10px;
  color: #475569;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.sc-order-action-message { margin: 12px 0; color: #4b5563; overflow-wrap: anywhere; }
.sc-order-action-dialog label { display: block; margin: 12px 0 6px; color: #374151; font-size: 13px; font-weight: 600; }
.sc-order-remarks-input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 116px;
  margin-top: 6px;
  padding: 10px 12px;
  box-sizing: border-box;
  resize: vertical;
  color: #111827;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
}
.sc-order-action-error { margin: 10px 0 0; color: #b91c1c; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.sc-order-action-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.sc-order-action-footer > button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
  cursor: pointer;
}
.sc-order-action-footer > .sc-order-action-cancel { color: #374151; background: #fff; border-color: #d1d5db; }
.sc-order-action-footer > .sc-order-action-submit { color: #fff; background: #2563eb; border-color: #1d4ed8; }
.sc-order-action-footer > .sc-order-action-submit.is-danger { background: #dc2626; border-color: #b91c1c; }
.sc-order-action-footer > .sc-order-action-submit.is-warning { background: #b45309; border-color: #92400e; }
.sc-order-action-dialog button:disabled,
.sc-order-remarks-input:disabled { opacity: .5; cursor: not-allowed; }
.sc-order-action-dialog button:focus-visible,
.sc-order-remarks-input:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
