/* Scheme 01 · 04-02 / 04-06. Presentation only, no controller or new fields.
 * Original cards, seven-column history, simple/full view and source boundary
 * remain authoritative. Sales application is not warehouse stock confirmation.
 */
@layer plan01 {
  body.erp-plan01 #shippingView {
    min-width: 0 !important;
    max-width: none !important;
    color: #172438 !important;
    background: #fff !important;
    font-variant-numeric: tabular-nums;

    & *, & *::before, & *::after { box-sizing: border-box; }
    & > * { order: 0 !important; min-width: 0; }
    /* The source marks a forbidden scope on this root. Its old generic deny
       rule lives in an unloaded theme; keep old records out of that state. */
    &.is-data-scope-forbidden > :not(.scoped-api-view-boundary) { display: none !important; }
    & > .section-bar {
      min-height: 0 !important;
      margin: 0 0 20px !important;
      padding: 0 !important;
      border: 0 !important;
      border-radius: 0 !important;
      background: #fff !important;
      box-shadow: none !important;
    }
    & > .section-bar h2 {
      margin: 0 0 6px !important;
      font-size: 29px !important;
      font-weight: 740 !important;
      line-height: 1.28 !important;
      letter-spacing: -.5px !important;
      color: #172438 !important;
    }
    & > .section-bar p {
      margin: 0 !important;
      color: #5b6b80 !important;
      font-size: 14px !important;
      line-height: 1.55 !important;
    }
    & > .panel {
      margin: 0 0 20px !important;
      padding: 0 !important;
      border: 0 !important;
      border-radius: 0 !important;
      box-shadow: none !important;
    }
    & .panel-header {
      flex-wrap: wrap;
      align-items: baseline !important;
      gap: 6px 16px !important;
      min-height: 0 !important;
      margin: 0 0 12px !important;
      padding: 0 !important;
      border: 0 !important;
      background: #fff !important;
    }
    & .panel-header h2 {
      margin: 0 !important;
      color: #172438 !important;
      font-size: 17px !important;
      font-weight: 650 !important;
      line-height: 1.5 !important;
    }
    & .panel-header span {
      color: #5b6b80 !important;
      font-size: 12px !important;
      line-height: 1.55 !important;
      white-space: normal !important;
    }
    & .module-grid {
      grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)) !important;
      gap: 0 !important;
      border: 1px solid #e0e9f0 !important;
      border-radius: 5px;
    }
    & .summary-jump-card {
      min-width: 0 !important;
      min-height: 0 !important;
      padding: 12px 16px !important;
      border: 0 !important;
      border-right: 1px solid #e0e9f0 !important;
      border-radius: 0 !important;
      background: #f4f8fa !important;
      text-align: left;
      box-shadow: none !important;
    }
    & .summary-jump-card :is(span, p, small) {
      color: #5b6b80 !important;
      font-size: 12px !important;
      line-height: 1.5 !important;
      overflow-wrap: anywhere;
    }
    & .summary-jump-card strong {
      margin: 4px 0 !important;
      color: #172438 !important;
      font-size: 18px !important;
      line-height: 1.4 !important;
    }
    & .summary-jump-card small { color: #087568 !important; }
    & #shippingResultBar {
      flex-wrap: wrap;
      gap: 8px 12px;
      margin: 12px 0 0 !important;
      padding: 12px !important;
      color: #5b6b80 !important;
      font-size: 13px !important;
      line-height: 1.5 !important;
    }
    & #shippingResultBar:empty { margin: 0 !important; padding: 0 !important; }
    & > .module-mini-nav {
      flex-wrap: wrap !important;
      gap: 8px !important;
      margin: 0 0 20px !important;
      padding: 0 !important;
      background: #fff !important;
      border: 0 !important;
      border-radius: 0 !important;
    }
    & > .module-mini-nav button {
      min-height: 39px !important;
      padding: 8px 20px !important;
      border: 1px solid #e0e9f0 !important;
      border-radius: 5px !important;
      background: #f4f8fa !important;
      color: #172438 !important;
      font-size: 13px !important;
      line-height: 1.5 !important;
      box-shadow: none !important;
    }
    & > .module-mini-nav button.active {
      color: #fff !important;
      background: #008575 !important;
      border-color: #008575 !important;
    }
    & #shipmentList {
      gap: 0 !important;
      min-width: 0;
      border: 1px solid #e0e9f0;
      border-radius: 5px;
    }
    & .shipment-card {
      grid-template-columns: minmax(0, 1fr) auto !important;
      align-items: center !important;
      gap: 12px 24px !important;
      min-width: 0 !important;
      padding: 16px 20px !important;
      margin: 0 !important;
      border: 0 !important;
      border-bottom: 1px solid #e0e9f0 !important;
      border-radius: 0 !important;
      background: #fff !important;
      box-shadow: none !important;
    }
    & .shipment-card:last-child { border-bottom: 0 !important; }
    & .shipment-card:first-child { background: #f6fcfa !important; }
    & .shipment-card > div { min-width: 0; }
    & .shipment-card h3 {
      margin: 0 0 4px !important;
      color: #172438 !important;
      font-size: 14px !important;
      font-weight: 600 !important;
      line-height: 1.6 !important;
      overflow-wrap: anywhere;
    }
    & .shipment-card p {
      margin: 0 0 8px !important;
      color: #5b6b80 !important;
      font-size: 13px !important;
      line-height: 1.65 !important;
      overflow-wrap: anywhere;
    }
    & .table-secondary-actions { flex-wrap: wrap; gap: 8px !important; margin: 0 !important; }
    & button {
      max-width: 100%;
      min-height: 36px !important;
      line-height: 1.45 !important;
      white-space: normal !important;
      overflow-wrap: anywhere;
      box-shadow: none !important;
    }
    & .text-button { padding: 4px 0 !important; text-align: left; }
    & .shipment-primary-action { min-width: 120px; min-height: 39px !important; padding: 8px 16px !important; }
    & .table-wrap {
      max-width: 100%;
      min-width: 0;
      padding: 0 !important;
      border: 1px solid #e0e9f0 !important;
      border-radius: 5px !important;
      overflow: auto !important;
      scrollbar-color: #9aabb9 #f4f8fa;
      scrollbar-width: thin;
      overscroll-behavior-x: contain;
    }
    & table {
      width: 100% !important;
      min-width: 980px !important;
      table-layout: fixed !important;
      border-collapse: collapse !important;
      font-size: 13px !important;
    }
    & :is(th, td) {
      padding: 12px !important;
      line-height: 1.55 !important;
      white-space: normal !important;
      overflow-wrap: anywhere;
      text-align: left !important;
    }
    & th { color: #485b73 !important; background: #f0f6f9 !important; }
    & td { color: #172438 !important; }
    & table :is(th, td):nth-child(1) { width: 21% !important; }
    & table :is(th, td):nth-child(2) { width: 13% !important; }
    & table :is(th, td):nth-child(3) { width: 15% !important; }
    & table :is(th, td):nth-child(4) { width: 10% !important; text-align: right !important; }
    & table :is(th, td):nth-child(5) { width: 12% !important; }
    & table :is(th, td):nth-child(6) { width: 14% !important; }
    & table :is(th, td):nth-child(7) { width: 15% !important; }
    & td[colspan] { width: auto !important; text-align: center !important; }
    & td small { color: #5b6b80 !important; font-size: 12px !important; }
    & .empty { padding: 24px 16px !important; color: #5b6b80 !important; line-height: 1.6; }
    & :is(button, .table-wrap):focus-visible { outline: 2px solid #008575 !important; outline-offset: 3px; }
    & button:disabled { opacity: .5 !important; cursor: not-allowed !important; }
    & ::selection { color: #172438; background: #d0f6eb; }
  }

  body.erp-plan01 :is(#shippingDispatchDialog, #warehouseShipmentConfirmDialog) {
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 32px);
    padding: 0 !important;
    border-radius: 5px !important;
    overflow: auto !important;
    scrollbar-color: #9aabb9 #f4f8fa;
    scrollbar-width: thin;
    overscroll-behavior: contain;

    & *, & *::before, & *::after { box-sizing: border-box; }
    & > form {
      width: 100% !important;
      min-width: 0 !important;
      max-width: none !important;
      height: auto !important;
      min-height: 100% !important;
      max-height: none !important;
      margin: 0 !important;
      padding: 24px 28px !important;
      border: 0 !important;
      border-radius: 0 !important;
      overflow: visible !important;
      color: #172438;
      font-variant-numeric: tabular-nums;
    }
    & .dialog-header {
      align-items: flex-start !important;
      gap: 16px !important;
      margin: 0 0 20px !important;
      padding: 0 !important;
      border: 0 !important;
      position: static !important;
    }
    & .dialog-header > div { min-width: 0; }
    & .dialog-header h2 {
      margin: 0 0 6px !important;
      font-size: 26px !important;
      font-weight: 740 !important;
      line-height: 1.35 !important;
      letter-spacing: -.5px;
      overflow-wrap: anywhere;
    }
    & .dialog-subtitle {
      margin: 0 0 16px !important;
      color: #5b6b80 !important;
      font-size: 13px !important;
      line-height: 1.6 !important;
      overflow-wrap: anywhere;
    }
    & .dialog-header .dialog-subtitle { margin: 0 !important; }
    & .simple-flow-banner {
      gap: 8px 12px;
      margin: 0 0 16px !important;
      padding: 16px !important;
      border: 1px solid #e0e9f0 !important;
      border-radius: 5px !important;
      background: #f4f8fa !important;
      color: #40536a !important;
      font-size: 13px !important;
      line-height: 1.6 !important;
      overflow-wrap: anywhere;
    }
    & .simple-flow-banner .form-error-note { color: #a82b25 !important; }
    & .form-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
      align-items: start !important;
      gap: 20px 24px !important;
      margin: 0 !important;
      padding: 20px !important;
      border: 1px solid #e0e9f0;
      border-radius: 5px;
    }
    & .form-grid label {
      min-width: 0;
      margin: 0 !important;
      gap: 8px;
      color: #172438 !important;
      font-size: 13px !important;
      line-height: 1.55 !important;
    }
    & .form-span-2 { grid-column: 1 / -1 !important; }
    & :is(input, select, textarea) {
      min-width: 0 !important;
      width: 100% !important;
      max-width: 100% !important;
      min-height: 39px !important;
      height: auto !important;
      color: #40536a !important;
      font-size: 13px !important;
      line-height: 1.5 !important;
      caret-color: #008575;
    }
    & textarea { resize: vertical; min-height: 88px !important; }
    & :is(input, textarea)::placeholder { color: #5b6b80 !important; opacity: 1; }
    & small { color: #5b6b80 !important; font-size: 12px !important; line-height: 1.55; }
    & #shippingFreightField.is-required small { color: #87500d !important; }
    & .dialog-footer {
      position: static !important;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 10px;
      margin: 24px 0 0 !important;
      padding: 20px 0 0 !important;
      border-top: 1px solid #e0e9f0;
      background: #fff !important;
    }
    & button { min-height: 39px !important; white-space: normal; }
    & .icon-button { flex: 0 0 44px; width: 44px !important; height: 44px !important; padding: 0 !important; font-size: 24px !important; }
    & button:disabled { opacity: .5 !important; cursor: not-allowed !important; }
    & :is(button, input, select, textarea):focus-visible { outline: 2px solid #008575 !important; outline-offset: 3px; }
    & ::selection { color: #172438; background: #d0f6eb; }
  }

  body.erp-plan01 #warehouseShipmentConfirmDialog { width: min(840px, calc(100vw - 32px)) !important; }
  body.erp-plan01 #warehouseShipmentConfirmDialog .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  @media (max-width: 980px) {
    body.erp-plan01 :is(#shippingDispatchDialog, #warehouseShipmentConfirmDialog) {
      inset: 0 !important;
      width: 100vw !important;
      max-width: 100vw !important;
      height: 100dvh !important;
      max-height: 100dvh !important;
      margin: 0 !important;
      border: 0 !important;
      border-radius: 0 !important;
      & > form { padding: 20px 16px max(20px, env(safe-area-inset-bottom)) !important; }
      & .form-grid { grid-template-columns: 1fr !important; gap: 20px !important; padding: 16px !important; }
      & .dialog-header h2 { font-size: 24px !important; }
      & :is(button, input, select, textarea) { min-height: 44px !important; }
      & .dialog-footer { padding-bottom: 4px !important; }
    }
  }
  @media (max-width: 600px) {
    body.erp-plan01 #shippingView {
      & .shipment-card { grid-template-columns: minmax(0, 1fr) !important; gap: 12px !important; padding: 16px !important; }
      & .shipment-primary-action { width: 100%; }
      & :is(button, .module-mini-nav button) { min-height: 44px !important; }
      & .panel-header { align-items: flex-start !important; }
      & .summary-jump-card { padding: 12px !important; }
    }
  }
}
