/* Desktop sales-order workspace: compact optional sections and user-resizable columns. */
@media (min-width: 901px) {
  #invoiceForm .invoice-title {
    padding-top: 16px;
    padding-bottom: 14px;
  }

  #invoiceForm .invoice-view-switch,
  #invoiceForm .order-mode-switch {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  #invoiceForm .invoice-customer {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  #invoiceForm .invoice-products {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  #invoiceForm .invoice-section-head {
    gap: 10px;
  }

  #invoiceForm .invoice-section-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
  }

  #invoiceForm .invoice-section-tools > button {
    margin: 0;
  }

  #invoiceForm .invoice-width-reset {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--store-theme-border, #bfd6ce);
    border-radius: 10px;
    background: #fff;
    color: var(--store-theme, #176b57);
    font-size: 12px;
    cursor: pointer;
  }

  #invoiceForm .invoice-products .table-wrap {
    position: relative;
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid var(--store-theme-border, #c9ddd6);
    border-radius: 12px;
    background: #fff;
    scrollbar-color: color-mix(in srgb, var(--store-theme, #176b57) 42%, transparent) transparent;
    scrollbar-width: thin;
  }

  #invoiceForm .invoice-resizable-table {
    width: var(--invoice-table-width, 100%) !important;
    min-width: 100% !important;
    table-layout: fixed !important;
    border: 0 !important;
  }

  #invoiceForm .invoice-resizable-table th,
  #invoiceForm .invoice-resizable-table td {
    width: auto !important;
    min-width: 0 !important;
  }

  #invoiceForm .invoice-resizable-table thead th {
    position: relative;
    height: 45px;
    padding-right: 13px !important;
    white-space: nowrap;
    user-select: none;
  }

  #invoiceForm .invoice-resizable-table th:last-child,
  #invoiceForm .invoice-resizable-table tbody tr:not(.processing-inline-row) > td:last-child {
    position: sticky;
    right: 0;
    z-index: 6;
    background: #fff !important;
    box-shadow: none;
  }

  #invoiceForm .invoice-resizable-table th:last-child {
    z-index: 10;
    background: var(--store-theme-faint, #edf6f2) !important;
  }

  #invoiceForm .invoice-resizable-table th:nth-last-child(2),
  #invoiceForm .invoice-resizable-table tbody tr:not(.processing-inline-row) > td:nth-last-child(2) {
    position: sticky;
    right: 190px;
    z-index: 5;
    overflow: hidden;
    background: #fff !important;
    box-shadow: -12px 0 20px -17px rgba(17, 58, 48, .78);
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  #invoiceForm .invoice-resizable-table th:nth-last-child(2) {
    z-index: 9;
    background: var(--store-theme-faint, #edf6f2) !important;
    text-align: center !important;
  }

  #invoiceForm .invoice-resizable-table tbody tr:not(.processing-inline-row) > td:nth-last-child(2) {
    padding-right: 16px !important;
    text-align: right !important;
    font-variant-numeric: tabular-nums;
  }

  #invoiceForm .invoice-col-resizer {
    position: absolute;
    z-index: 8;
    top: 7px;
    right: -5px;
    width: 10px;
    height: calc(100% - 14px);
    cursor: col-resize;
    touch-action: none;
  }

  #invoiceForm .invoice-col-resizer::after {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: 2px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--store-theme, #176b57) 26%, transparent);
    transition: background .16s ease, transform .16s ease;
  }

  #invoiceForm .invoice-col-resizer:hover::after,
  #invoiceForm .invoice-col-resizer.is-dragging::after {
    background: var(--store-theme, #176b57);
    transform: scaleX(1.6);
  }

  body.invoice-column-resizing,
  body.invoice-column-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
  }

  #invoiceForm .invoice-resizable-table td {
    height: 66px;
  }

  #invoiceForm .invoice-resizable-table .processing-note-cell,
  #invoiceForm .invoice-resizable-table .processing-note-head {
    display: none !important;
  }

  #invoiceForm .invoice-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    width: 100%;
  }

  #invoiceForm .invoice-row-actions .processing-detail-button {
    min-width: 84px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--store-theme-border, #b9d4ca);
    border-radius: 10px;
    background: var(--store-theme-faint, #edf6f2);
    color: var(--store-theme, #176b57);
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
  }

  #invoiceForm .invoice-row-actions .processing-detail-button:hover {
    border-color: var(--store-theme, #176b57);
    background: #fff;
  }

  #invoiceForm .invoice-row-actions .danger {
    flex: 0 0 54px;
    width: 54px;
    height: 38px;
    margin: 0;
    border-radius: 10px;
    padding: 0 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  #invoiceForm .processing-inline-row .processing-inline-actions,
  #invoiceForm .processing-inline-row button {
    display: none !important;
  }

  #invoiceForm .processing-inline-row td {
    height: auto;
    padding: 8px 16px !important;
    background: linear-gradient(90deg, var(--store-theme-faint, #f2f8f6), #fff) !important;
  }

  #invoiceForm .invoice-optional-section {
    position: relative;
    margin: 12px 20px;
    padding: 14px 18px 16px;
    border: 1px solid var(--store-theme-border, #c7dcd5);
    border-radius: 18px;
    background: linear-gradient(135deg, #fff 0%, var(--store-theme-faint, #f2f8f6) 100%);
    box-shadow: 0 8px 24px rgba(25, 82, 68, .06);
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
  }

  #invoiceForm .invoice-optional-section > h3 {
    display: flex;
    align-items: center;
    min-height: 44px;
    margin: 0 !important;
    padding: 0 126px 0 0 !important;
    border-bottom: 0 !important;
    cursor: pointer;
  }

  #invoiceForm .invoice-optional-section > h3::before {
    content: "配";
    display: inline-grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    margin-right: 12px;
    border-radius: 12px;
    background: var(--store-theme, #176b57);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 6px 15px rgba(23, 107, 87, .18);
  }

  #invoiceForm .invoice-optional-business > h3::before {
    content: "返";
    background: #b77824;
    box-shadow: 0 6px 15px rgba(183, 120, 36, .18);
  }

  #invoiceForm .invoice-optional-section > h3 small {
    margin-left: 12px;
    color: #81908c;
    font-weight: 500;
  }

  #invoiceForm .invoice-section-toggle {
    position: absolute;
    top: 15px;
    right: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-width: 112px;
    height: 40px;
    padding: 0 8px 0 14px;
    border: 1px solid var(--store-theme-border, #bfd6ce);
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    color: var(--store-theme, #176b57);
    box-shadow: 0 5px 14px rgba(23, 107, 87, .08);
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  }

  #invoiceForm .invoice-section-toggle:hover {
    transform: translateY(-1px);
    border-color: var(--store-theme, #176b57);
    box-shadow: 0 7px 18px rgba(23, 107, 87, .14);
  }

  #invoiceForm .invoice-toggle-text {
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
  }

  #invoiceForm .invoice-section-toggle i {
    position: relative;
    display: block;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--store-theme-faint, #edf6f3);
  }

  #invoiceForm .invoice-section-toggle i::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 9px;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .2s ease, top .2s ease;
  }

  #invoiceForm .invoice-section-toggle[aria-expanded="true"] i::before {
    top: 10px;
    transform: rotate(225deg);
  }

  #invoiceForm .invoice-optional-section.is-collapsed {
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 4px 14px rgba(25, 82, 68, .035);
  }

  #invoiceForm .invoice-optional-section.is-collapsed .form-grid {
    display: none;
  }

  #invoiceForm .invoice-optional-section.is-collapsed:hover {
    border-color: var(--store-theme, #176b57);
  }
}

@media (max-width: 900px) {
  #invoiceForm .invoice-optional-section {
    margin: 10px 12px;
    padding: 12px 14px;
    border-radius: 15px;
  }

  #invoiceForm .invoice-optional-section > h3 {
    min-height: 42px;
    padding-right: 48px !important;
  }

  #invoiceForm .invoice-optional-section > h3 small {
    display: none;
  }

  #invoiceForm .invoice-section-toggle {
    top: 14px;
    right: 13px;
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
  }

  #invoiceForm .invoice-toggle-text {
    display: none;
  }

  #invoiceForm .invoice-width-reset {
    display: none;
  }

  #invoiceForm .invoice-row-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
  }

  #invoiceForm .invoice-row-actions .processing-detail-button {
    min-height: 38px;
    white-space: nowrap;
  }
}
