/* API workspace: a contained desktop layout with native, accessible controls. */
body.api-workspace { background: #0c1116 !important; color-scheme: dark; }
body.api-workspace .app-shell { max-width: 1240px; width: 100%; margin: 0 auto; border: 0; border-radius: 0; overflow: visible; box-shadow: none; background: #0c1116 !important; }
body.api-workspace .main-screen { min-height: 100vh; padding: 28px 32px 100px; background: #0c1116 !important; }
#pageApi { --api-border: #2b3944; --api-panel: #141c23; --api-text: #e8eef2; --api-muted: #9baab5; --api-accent: #37d2b3; }
#pageApi *, #pageApi *::before, #pageApi *::after { box-sizing: border-box; }
#pageApi .api-page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
#pageApi h1 { margin: 0; font-size: 30px; font-weight: 750; line-height: 1.25; letter-spacing: -.6px; color: var(--api-text) !important; }
#pageApi .api-page-header p { margin: 8px 0 0; color: var(--api-muted); font-size: 14px; line-height: 1.5; }
#pageApi button { font-size: 14px; font-weight: 600; min-height: 44px; border-radius: 7px; }
#pageApi button:focus-visible, #pageApi input:focus-visible, #pageApi select:focus-visible, #pageApi summary:focus-visible, #pageApi [tabindex]:focus-visible { outline: 2px solid var(--api-accent); outline-offset: 3px; }
#pageApi .ghost-btn { border: 1px solid var(--api-border) !important; background: transparent !important; color: var(--api-text) !important; padding: 10px 16px; box-shadow: none; }
#pageApi .primary-btn { border: 1px solid var(--api-accent); background: var(--api-accent) !important; color: #071c18 !important; padding: 11px 18px; box-shadow: none; }
#pageApi .primary-btn:hover:not(:disabled) { background: #62e1c8 !important; }
#pageApi .text-btn { color: var(--api-accent); padding: 8px; background: transparent; border: 0; }
#pageApi button:disabled { opacity: .45; cursor: not-allowed; }
#pageApi .api-refresh, #pageApi #reloadRetriesBtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
#pageApi svg { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }
#pageApi .api-exchanges { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 12px; margin-bottom: 24px; }
#pageApi .api-exchange { display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid var(--api-border); background: var(--api-panel); color: var(--api-text); text-align: left; min-width: 0; }
#pageApi .api-exchange.is-active { border-color: var(--api-accent); box-shadow: inset 0 0 0 1px var(--api-accent); }
#pageApi .api-exchange-icon { flex-shrink: 0; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #54636e; border-radius: 5px; color: #d9e6ed; font-size: 14px; font-weight: 500; }
#pageApi .api-exchange-copy { display: grid; gap: 5px; min-width: 0; }
#pageApi .api-exchange-copy strong { color: var(--api-text); font-size: 15px; }
#pageApi .api-exchange-copy > span { font-size: 12px; white-space: nowrap; }
#pageApi .api-tone-ok { color: var(--api-accent) !important; }
#pageApi .api-tone-error { color: #ff827b !important; }
#pageApi .api-tone-pending { color: #e8c26b !important; }
#pageApi .api-tone-muted, #pageApi .api-muted { color: var(--api-muted) !important; }
#pageApi .api-content-grid { display: grid; grid-template-columns: minmax(320px, .9fr) minmax(0,1.6fr); gap: 20px; align-items: start; }
#pageApi .api-panel { min-width: 0; border: 1px solid var(--api-border); border-radius: 7px; background: var(--api-panel); overflow: hidden; }
#pageApi .api-panel-heading { padding: 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--api-border); }
#pageApi h2 { color: var(--api-text) !important; font-size: 19px; font-weight: 650; line-height: 1.4; margin: 0; }
#pageApi .api-panel-heading p { color: var(--api-muted); font-size: 13px; margin: 4px 0 0; line-height: 1.5; }
#pageApi .api-environment { border: 1px solid #2a6d63; color: var(--api-accent); font-size: 12px; padding: 3px 7px; border-radius: 4px; }
#pageApi #apiForm { padding: 20px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
#pageApi #apiForm > label:not(.api-trade-check), #pageApi .api-passphrase > label { display: block; margin: 10px 0 0; padding: 0; font-size: 13px; font-weight: 500; color: #c7d1d8; line-height: 1.5; }
#pageApi #apiForm > label:first-of-type { margin-top: 0; }
#pageApi input:not([type=checkbox]):not([type=hidden]), #pageApi select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #42525f !important; border-radius: 5px; background: #10171d !important; padding: 10px 12px; font-size: 16px; font-weight: 400; line-height: 1.4; color: var(--api-text) !important; margin: 0; box-shadow: none; }
#pageApi input::placeholder { color: #84949e; font-size: 14px; }
#pageApi .api-field-help { font-size: 11px; color: var(--api-muted); line-height: 1.5; }
#pageApi .api-secret-field { display: flex; align-items: center; position: relative; }
#pageApi .api-secret-field input { padding-right: 48px !important; }
#pageApi .api-reveal { position: absolute; inset-inline-end: 0; border: 0; background: transparent; color: var(--api-muted); width: 44px; min-height: 44px; padding: 10px; }
#pageApi .api-passphrase:not([hidden]) { display: flex; flex-direction: column; gap: 8px; }
#pageApi .api-passphrase[hidden] { display: none; }
#pageApi .api-trade-check { display: flex; flex-direction: row; gap: 10px; align-items: center; justify-content: flex-start; min-height: 44px; margin-top: 8px; font-size: 14px; cursor: pointer; }
#pageApi input[type=checkbox] { accent-color: var(--api-accent); width: 18px; height: 18px; min-height: 18px; padding: 0; margin: 0; cursor: pointer; }
#pageApi .api-form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
#pageApi .api-connection-feedback { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; font-size: 12px; line-height: 1.5; }
#pageApi .api-connection-feedback small { font-size: 11px; color: var(--api-muted); }
#pageApi .retry-filters { display: flex; align-items: center; gap: 10px; padding: 16px; }
#pageApi .retry-filters select { font-size: 13px; flex: 1 1 100px; }
#pageApi #reloadRetriesBtn { flex-shrink: 0; padding: 10px; font-size: 12px; }
#pageApi .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
#pageApi .retry-table-wrap { container-type: inline-size; max-width: 100%; max-height: 510px; overflow: auto; margin: 0 12px; border: 1px solid var(--api-border); border-radius: 5px; }
#pageApi .retry-table { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; font-size: 12px; line-height: 1.5; text-align: left; color: var(--api-text); }
#pageApi .retry-table thead { position: sticky; top: 0; z-index: 1; background: #1c262e; }
#pageApi .retry-table thead th { font-weight: 500; color: #c7d3da; padding: 0 8px; height: 44px; border-bottom: 1px solid var(--api-border); }
#pageApi .retry-table thead th:first-child { width: 44px; padding: 0; }
#pageApi .retry-table thead th:nth-child(2) { width: 38%; }
#pageApi .retry-table thead th:nth-child(3) { width: 31%; }
#pageApi .retry-table tbody td, #pageApi .retry-table tbody th { padding: 12px 8px; vertical-align: top; border-bottom: 1px solid var(--api-border); font-weight: 400; overflow-wrap: anywhere; }
#pageApi .retry-table tbody tr:last-child > * { border-bottom: 0; }
#pageApi .retry-table tbody tr.is-selected { background: #14342f; }
#pageApi .retry-table .retry-checkbox-cell { padding: 0; }
#pageApi .retry-select-label { display: flex; align-items: center; justify-content: center; width: 44px; min-height: 48px; margin: 0; cursor: pointer; }
#pageApi .retry-record-title { display: flex; flex-wrap: wrap; gap: 7px; color: #aebec8; }
#pageApi .retry-record-title strong { color: var(--api-text); font-weight: 650; }
#pageApi .retry-symbol { display: block; font-size: 11px; color: #b0bec7; margin-top: 3px; }
#pageApi .retry-action-name { display: inline-block; margin-top: 3px; color: #d3e1e9; }
#pageApi .retry-status { display: inline-block; border: 1px solid #536271; border-radius: 4px; padding: 1px 5px; font-size: 11px; white-space: nowrap; }
#pageApi .retry-status-failed { color: #ff8d84; border-color: #804943; }
#pageApi .retry-status-pending { color: #e9c372; border-color: #75613e; }
#pageApi .retry-status-completed { color: var(--api-accent); border-color: #306b60; }
#pageApi .retry-status-running { color: #8cbde9; border-color: #40627e; }
#pageApi .retry-attempts { display: block; font-size: 11px; color: #a6b5bf; margin-top: 4px; }
#pageApi time { display: block; color: #96a9b5; font-size: 10px; white-space: nowrap; margin-top: 3px; }
#pageApi .retry-error-cell details { margin-top: 1px; }
#pageApi .retry-error-cell summary { display: flex; align-items: center; gap: 2px; cursor: pointer; list-style: none; color: var(--api-accent); font-size: 12px; min-height: 28px; white-space: nowrap; }
#pageApi .retry-error-cell summary::-webkit-details-marker { display: none; }
#pageApi .retry-error-cell summary svg { width: 13px; height: 13px; }
#pageApi .retry-error-cell details[open] summary svg { transform: rotate(90deg); }
#pageApi .retry-error-cell p, #pageApi .retry-error-cell small { display: block; font-size: 11px; line-height: 1.6; color: #b9c7cf; margin: 8px 0 0; overflow-wrap: anywhere; }
#pageApi .retry-footer { padding: 16px 20px; margin-top: 12px; border-top: 1px solid var(--api-border); }
#pageApi .retry-action-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#pageApi #retrySelectionCount { font-size: 13px; font-weight: 600; color: var(--api-text); }
#pageApi #clearRetrySelection { font-size: 12px; }
#pageApi #runRetryBtn { margin-inline-start: auto; }
#pageApi .retry-footer > p { font-size: 12px; color: #aabac4; margin: 10px 0 0; line-height: 1.65; }
#pageApi .retry-footer > p.retry-execution-note { font-size: 11px; color: #95a7b3; margin-top: 4px; }
#pageApi .retry-feedback { color: var(--api-accent); font-size: 12px; line-height: 1.6; margin-top: 8px; }
#pageApi .retry-empty { min-height: 190px; display: grid; align-content: center; justify-items: center; padding: 30px 20px; gap: 8px; color: #b3c2cb; text-align: center; }
#pageApi .retry-empty strong { font-size: 14px; color: #e0e8ee; }
#pageApi .retry-empty p { font-size: 12px; line-height: 1.6; margin: 0; }
body.api-workspace .bottom-nav { width: 100%; max-width: 1240px; left: 50%; bottom: 0; transform: translateX(-50%); border: 0; border-top: 1px solid #2b3944; border-radius: 0; background: #0c1116 !important; box-shadow: none; backdrop-filter: none; height: 68px; padding: 0 max(20px,calc((100% - 540px)/2)); }
body.api-workspace .bottom-nav button { position: relative; font-size: 14px; min-width: 70px; color: #a8b7c1; }
body.api-workspace .bottom-nav button > span { display: none; }
body.api-workspace .bottom-nav button.active { background: transparent; color: #37d2b3; }
body.api-workspace .bottom-nav button.active::after { content: ''; position: absolute; bottom: 8px; left: 25%; right: 25%; height: 3px; background: #37d2b3; border-radius: 2px; }
@container (width < 500px) {
  #pageApi .retry-table, #pageApi .retry-table tbody, #pageApi .retry-table tr, #pageApi .retry-table th, #pageApi .retry-table td { display: block; width: auto; }
  #pageApi .retry-table thead { display: block; }
  #pageApi .retry-table thead tr { display: flex; }
  #pageApi .retry-table thead th:not(:first-child) { display: none; }
  #pageApi .retry-table thead th:first-child { width: 100%; border-bottom: 1px solid var(--api-border); }
  #pageApi .retry-table thead .retry-select-label { width: auto; justify-content: flex-start; gap: 12px; padding-inline: 14px; }
  #pageApi .retry-table thead .retry-select-label::after { content: '选择当前可补推记录'; font-size: 12px; color: #b5c4cd; }
  #pageApi .retry-table tbody tr { position: relative; padding: 14px 14px 14px 54px; border-bottom: 1px solid var(--api-border); }
  #pageApi .retry-table tbody tr:last-child { border-bottom: 0; }
  #pageApi .retry-table tbody td, #pageApi .retry-table tbody th { padding: 0; border: 0; }
  #pageApi .retry-table .retry-checkbox-cell { position: absolute; top: 6px; left: 0; }
  #pageApi .retry-table tbody th { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
  #pageApi .retry-symbol { font-size: 11px; }
  #pageApi .retry-table td[data-label] { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px; margin-top: 7px; }
  #pageApi .retry-table td[data-label]::before { content: attr(data-label) '：'; color: #8497a4; font-size: 11px; }
  #pageApi .retry-table .retry-error-cell { display: block; }
  #pageApi .retry-error-cell::before { display: none; }
  #pageApi .retry-attempts, #pageApi time { display: inline; margin: 0; }
}
@media (max-width: 960px) {
  #pageApi .api-content-grid { grid-template-columns: 1fr; }
  #pageApi .api-exchanges { display: flex; overflow-x: auto; padding-bottom: 4px; gap: 10px; }
  #pageApi .api-exchange { flex: 0 0 155px; }
}
@media (max-width: 600px) {
  body.api-workspace .main-screen { padding: 22px 14px 92px; }
  #pageApi h1 { font-size: 25px; }
  #pageApi .api-page-header { gap: 10px; margin-bottom: 20px; }
  #pageApi .api-page-header p { font-size: 12px; }
  #pageApi .api-refresh { padding: 8px 10px; font-size: 12px; }
  #pageApi .api-exchanges { margin-bottom: 16px; }
  #pageApi .api-exchange { flex-basis: 142px; padding: 12px; gap: 10px; }
  #pageApi .api-panel-heading { padding: 16px; }
  #pageApi #apiForm { padding: 16px; }
  #pageApi .retry-filters { flex-wrap: wrap; padding: 14px 12px; }
  #pageApi .retry-filters select { flex-basis: calc(50% - 8px); }
  #pageApi #reloadRetriesBtn { width: 100%; }
  #pageApi .retry-footer { padding: 14px; }
  #pageApi .retry-action-row { gap: 5px; }
  #pageApi #runRetryBtn { font-size: 13px; padding-inline: 12px; }
  body.api-workspace .bottom-nav { padding: 0 18px; }
}

/* Override legacy full-width buttons only inside the new API workspace. */
#pageApi { font-family: Inter, ui-sans-serif, system-ui, "WenQuanYi Micro Hei", sans-serif; }
#pageApi button { width: auto; margin: 0; }
#pageApi .api-page-header > div { flex: 1 1 auto; min-width: 0; }
#pageApi .api-page-header h1 { white-space: nowrap; }
#pageApi .api-refresh { flex: 0 0 auto; }
#pageApi .api-form-actions button { display: flex; align-items: center; justify-content: center; width: 100%; }
#pageApi .retry-filters select { flex: 1 1 130px; }
#pageApi #reloadRetriesBtn { flex: 0 0 auto; }
#pageApi #clearRetrySelection { margin: 0; width: auto; }
#pageApi .retry-table { font-size: 13px; }
body.api-workspace .bottom-nav button.active { border-color: transparent; box-shadow: none; }
@media (max-width: 600px) {
  #pageApi .retry-filters select { flex: 1 1 calc(50% - 8px); }
  #pageApi #reloadRetriesBtn { flex: 0 0 100%; width: 100%; }
}
#pageApi input:not([type=checkbox]):not([type=hidden]), #pageApi select { height: 44px; }
body.api-workspace .app-shell::before { display: none; }
body.api-workspace .bottom-nav button.active { border: 0 !important; background: transparent !important; border-radius: 0; box-shadow: none !important; }
@media (min-width: 961px) {
  #pageApi #apiForm { display: grid; grid-template-columns: 88px minmax(0,1fr); align-items: center; gap: 18px 12px; }
  #pageApi #apiForm > label:not(.api-trade-check), #pageApi .api-passphrase > label { margin: 0; }
  #pageApi .api-field-help { grid-column: 2; margin-top: -12px; }
  #pageApi .api-passphrase:not([hidden]) { display: contents; }
  #pageApi .api-trade-check, #pageApi .api-form-actions, #pageApi .api-connection-feedback { grid-column: 1 / -1; margin: 0; }
  #pageApi .api-connection-feedback { margin-top: -6px; }
}
