/* Merchant CS center, phone width only.
   Marketplace order list: status on top, key fields in the middle, one action row at the bottom.
   Desktop tables are unchanged. Buttons stay the ones the page already rendered. */

@media (max-width: 767px) {
  html[data-mp="cs"] .mp-layout__content {
    background: #f3f4f6;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Chat sits in the column under the header. Do not size it from the viewport:
     that count includes the header again, so the list paints under the tab bar. */
  html[data-mp="cs"] .mp-layout__content--chat {
    padding: 0 0 calc(72px + env(safe-area-inset-bottom, 0px)) 0 !important;
    overflow: hidden !important;
    box-sizing: border-box;
  }

  html[data-mp="cs"] .mp-header__brand-text {
    display: none !important;
  }

  html[data-mp="cs"] .mp-assist__fab-badge {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
    right: 12px !important;
    z-index: 930;
  }

  /* In a thread the composer owns the bottom edge. Lift the assist button above it. */
  html[data-mp="cs"][data-cs-chat="thread"] .mp-assist__fab-badge {
    bottom: calc(156px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html[data-mp="cs"] .ant-table-wrapper,
  html[data-mp="cs"] .ant-table,
  html[data-mp="cs"] .ant-table-container {
    background: transparent !important;
  }

  html[data-mp="cs"] .ant-table-content,
  html[data-mp="cs"] .ant-table-body,
  html[data-mp="cs"] .ant-table-header {
    overflow: visible !important;
  }

  html[data-mp="cs"] .ant-table-thead {
    display: none !important;
  }

  html[data-mp="cs"] .ant-table-content > table,
  html[data-mp="cs"] .ant-table-body > table,
  html[data-mp="cs"] .ant-table-tbody {
    display: block;
    width: 100% !important;
  }

  html[data-mp="cs"] colgroup {
    display: none !important;
  }

  html[data-mp="cs"] .ant-table-measure-row,
  html[data-mp="cs"] .mp-market-empty {
    display: none !important;
  }

  html[data-mp="cs"] .ant-table-tbody > tr.ant-table-row {
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 0 0 10px;
    padding: 12px 12px 10px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }

  html[data-mp="cs"] .ant-table-tbody > tr.ant-table-row > td {
    width: auto !important;
    max-width: none !important;
    white-space: normal !important;
    background: transparent !important;
    border: none !important;
    padding: 3px 0 !important;
  }

  html[data-mp="cs"] .mp-market-check {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    width: auto !important;
    padding: 0 !important;
  }

  html[data-mp="cs"] .mp-market-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.35;
    color: #1a1a1a;
    padding: 0 28px 8px 0 !important;
    margin-bottom: 4px;
    border-bottom: 1px solid #f2f2f2 !important;
  }

  html[data-mp="cs"] .mp-market-field {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    line-height: 1.4;
  }

  html[data-mp="cs"] .mp-market-field::before {
    content: attr(data-label);
    flex: 0 0 42%;
    color: #8c8c8c;
    font-weight: 500;
  }

  html[data-mp="cs"] .mp-market-action {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    padding-top: 10px !important;
    border-top: 1px solid #f0f0f0 !important;
  }

  html[data-mp="cs"] .mp-market-action .ant-btn {
    min-height: 36px;
    border-radius: 18px;
    padding-inline: 14px;
  }

  html[data-mp="cs"] .mp-market-action .ant-btn:only-child {
    flex: 1 1 auto;
  }

  html[data-mp="cs"] .ant-pagination {
    margin: 4px 0 12px !important;
    justify-content: center;
  }

  /* Live chat: list of conversations, then the thread. Same pattern as a marketplace inbox. */
  html[data-mp="cs"] .mp-chat {
    flex: 1 1 auto;
    flex-direction: column;
    height: auto !important;
    min-height: 0;
    max-height: 100%;
    width: 100%;
    border: none;
    border-radius: 0;
    background: #f3f4f6;
  }

  html[data-mp="cs"] .mp-chat__rooms,
  html[data-mp="cs"] .mp-chat__windows,
  html[data-mp="cs"] .mp-chat__window,
  html[data-mp="cs"] .mp-chat__messages {
    min-height: 0;
  }

  html[data-mp="cs"] .mp-chat__rooms {
    width: 100%;
    flex: 1 1 auto;
    height: auto;
    overflow: hidden;
    border-right: none;
    background: #f3f4f6;
  }

  html[data-mp="cs"] .mp-chat__rooms-head {
    flex: none;
  }

  html[data-mp="cs"] .mp-chat__rooms-list {
    background: #f3f4f6;
    padding-top: 8px;
    /* The assist button floats over this list. The gap lets the last card scroll clear of it. */
    padding-bottom: 96px;
  }

  html[data-mp="cs"] .mp-chat__windows {
    flex: 1 1 auto;
    width: 100%;
  }

  html[data-mp="cs"][data-cs-chat="thread"] .mp-chat__messages {
    padding-bottom: 104px;
  }

  html[data-mp="cs"] .mp-chat__room {
    margin: 0 10px 8px;
    padding: 12px;
    background: #fff;
    border: 1px solid #eee;
    border-left: none;
    border-radius: 12px;
    align-items: flex-start;
  }

  html[data-mp="cs"] .mp-chat__room-main {
    flex: 1;
    min-width: 0;
  }

  html[data-mp="cs"] .mp-chat__room-preview {
    color: #666;
    font-size: 13px;
    margin-top: 4px;
  }

  html[data-mp="cs"][data-cs-chat="list"] .mp-chat__window {
    display: none !important;
  }

  html[data-mp="cs"][data-cs-chat="thread"] .mp-chat__rooms {
    display: none !important;
  }

  html[data-mp="cs"][data-cs-chat="thread"] .mp-chat__window {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    background: #fff;
  }

  html[data-mp="cs"] .mp-market-back {
    display: none;
    width: 36px;
    height: 36px;
    margin-right: 4px;
    border: none;
    border-radius: 18px;
    background: #f3f4f6;
    color: #1a1a1a;
    font-size: 24px;
    line-height: 1;
    flex: none;
    align-items: center;
    justify-content: center;
  }

  html[data-mp="cs"][data-cs-chat="thread"] .mp-market-back {
    display: inline-flex;
  }

  html[data-mp="cs"] .mp-chat__inputbar {
    flex: none;
    padding-bottom: 8px;
  }

  /* Chat settings dialog. Three mode cards in a row become one character wide,
     and the title tooltip paints a second "聊天设置" over the header. */
  html[data-mp="cs"] .ant-modal {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    top: 12px;
    margin: 0 auto;
    padding-bottom: 0;
  }

  html[data-mp="cs"] .ant-modal-content {
    border-radius: 16px;
    overflow: hidden;
  }

  html[data-mp="cs"] .ant-modal-header {
    padding: 14px 40px 8px 16px;
    margin-bottom: 0;
  }

  html[data-mp="cs"] .ant-modal-title {
    overflow: visible !important;
    white-space: normal !important;
    text-overflow: unset !important;
    width: auto !important;
    max-width: 100%;
  }

  html[data-mp="cs"] .ant-tooltip[data-mp-hide="1"] {
    display: none !important;
  }

  html[data-mp="cs"] .mp-cset {
    min-height: 0;
    max-height: calc(100dvh - 88px);
  }

  html[data-mp="cs"] .mp-cset__tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 8px;
  }

  html[data-mp="cs"] .mp-cset__tab {
    flex: 1 0 auto;
    white-space: nowrap;
    padding: 12px 10px;
    font-size: 14px;
    text-align: center;
  }

  html[data-mp="cs"] .mp-cset__body {
    padding: 12px;
  }

  html[data-mp="cs"] .mp-cset__mode-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  html[data-mp="cs"] .mp-cset__mode-card {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    grid-template-areas: "icon label" "icon desc";
    column-gap: 12px;
    row-gap: 2px;
    align-items: center;
    text-align: left;
    padding: 12px 36px 12px 14px;
  }

  html[data-mp="cs"] .mp-cset__mode-icon {
    grid-area: icon;
    margin: 0;
    font-size: 26px;
  }

  html[data-mp="cs"] .mp-cset__mode-label {
    grid-area: label;
    margin: 0;
  }

  html[data-mp="cs"] .mp-cset__mode-desc {
    grid-area: desc;
    line-height: 1.4;
  }

  html[data-mp="cs"] .mp-cset__mode-check {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
  }

  html[data-mp="cs"] .mp-cset__provider-row,
  html[data-mp="cs"] .mp-cset__key-row {
    flex-direction: column;
    align-items: stretch;
  }

  html[data-mp="cs"] .mp-cset__footer {
    padding: 12px;
  }

  html[data-mp="cs"] .mp-cset__footer .ant-btn {
    min-height: 40px;
    border-radius: 20px;
    padding-inline: 16px;
  }
}
