.otc-page { padding-block: 22px 56px; }
.market-head, .pair-identity, .market-meta, .market-switch, .account-bar,
.panel-head, .dialog-head, .notice { display: flex; align-items: center; }
.market-overview { border: 1px solid #34505e; border-radius: 15px; background: #172833; overflow: hidden; margin-bottom: 11px; }
.market-head { justify-content: space-between; gap: 15px; padding: 17px 20px; background: radial-gradient(ellipse at 88% 0%, #21484a9e, transparent 70%), linear-gradient(115deg, #172c37, #192c35); }
.pair-identity { gap: 14px; min-width: 0; }
.pair-identity h1 { margin: 0; font-size: clamp(29px, 5vw, 46px); }
.pair-identity .token-pair .token-mark + .token-mark { box-shadow: -3px 0 0 var(--bg); }
.market-meta { gap: 8px; margin-top: 4px; color: var(--muted); font-size: 13px; }
.sandbox { padding: 2px 7px; border-radius: 5px; border: 1px solid #3b6358; background: #18322d; color: var(--mint); font-size: 12px; }
.market-switch, .segmented { display: flex; gap: 3px; padding: 3px; background: var(--well); border: 1px solid var(--line); border-radius: 9px; }
.market-switch button, .segmented button { min-width: 0; border-color: transparent; background: transparent; color: var(--muted); font-weight: 650; }
.market-switch button[aria-pressed=true], .segmented button[aria-pressed=true] { background: #233646; border-color: #365064; color: var(--text); }

.otc-page button, dialog button, .otc-page input, dialog input, .otc-page select { min-height: 44px; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--well); color: var(--text); }
.otc-page button:hover:not(:disabled), dialog button:hover:not(:disabled) { border-color: var(--mint); }
.otc-page button:disabled, dialog button:disabled { opacity: .48; }
.otc-page .primary, dialog .primary { border-color: var(--mint); background: var(--mint); color: #102521; font-weight: 730; }
.otc-page button[data-direction=sell], dialog button[data-direction=sell] { background: #54333e; border-color: #8a535e; color: #ffdae0; }
.market-switch button, .segmented button { border-color: transparent; background: transparent; color: var(--muted); font-size: 14px; }
.market-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-block: 1px solid #314554; background: #101e2a; }
.market-metrics > div { min-width: 0; padding: 12px 20px; }
.market-metrics > div + div { border-inline-start: 1px solid #293d4a; }
.market-metrics dt { color: var(--muted); font-size: 13px; }
.market-metrics dd { margin: 4px 0 0; overflow-wrap: anywhere; font: 680 clamp(14px, 2.1vw, 20px)/1.3 var(--mono); }
.metric-ask dd { color: var(--mint); }
.metric-bid dd { color: var(--rose); }
.account-bar { justify-content: space-between; gap: 12px 18px; padding: 8px 16px; background: #152430; }
.account-bar label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.account-bar select { width: auto; }
.account-bar p { margin: 0; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; overflow-wrap: anywhere; }
.balance-label { color: var(--muted); }
.balance-value { display: inline-block; }
.trade-help { margin: 0 0 13px; border: 1px solid var(--line); border-radius: 9px; background: #131f2c; }
.trade-help summary, .market-depth summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; min-height: 44px; padding-inline: 12px; font-size: 14px; font-weight: 660; }
.trade-help summary::after, .market-depth summary::after { content: '＋'; color: var(--muted); }
.trade-help[open] summary::after, .market-depth[open] summary::after { content: '−'; }
.trade-help summary span, .market-depth summary span { margin-inline-start: auto; color: var(--muted); font-size: 12px; font-weight: 500; }
.trade-help dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 2px 12px 12px; }
.trade-help dt { font-weight: 680; font-size: 14px; }
.trade-help dd { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.trade-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0 0 14px; }
.trade-nav button { display: grid; align-content: center; gap: 3px; min-height: 61px; font-weight: 700; padding-inline: 6px; line-height: 1.2; background: #152331; }
.trade-nav small { color: var(--muted); font-size: 12px; font-weight: 500; }
.trade-nav button[aria-pressed=true] { color: var(--mint); background: #203a37; border-color: #4b7d70; }
.trade-nav button[data-mode=sell][aria-pressed=true] { color: #ffd6db; background: #4a2e3a; border-color: #7b4d59; }
.notice { flex-wrap: wrap; justify-content: space-between; gap: 5px 12px; padding: 8px 12px; margin: 0 0 14px; border: 1px solid #3a6557; border-radius: 9px; background: #172e2b; color: #b9f1db; }
.notice p { margin: 0; }
.notice[data-error=true] { border-color: #854d57; background: #3a232b; color: var(--error); }
.otc-page .text-button { padding: 0 4px; border: 0; background: transparent; color: var(--mint); text-decoration: underline; }

.trade-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 14px; align-items: start; }
.otc-panel { min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: #142130; }
.sweep-panel { background: linear-gradient(151deg, #1b3038, #142130 55%); }
.panel-head { justify-content: space-between; gap: 10px; padding: 17px 17px 13px; }
.panel-head h2, .dialog-head h2 { margin: 0 0 3px; font-size: 20px; }
.panel-head p, .dialog-head p { margin: 0; font-size: 14px; }
.order-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.book-meta { display: grid; justify-items: end; gap: 2px; }
.sweep-jump { display: none; font-size: 13px; white-space: nowrap; }
.book-table { width: 100%; border-collapse: collapse; text-align: right; font-variant-numeric: tabular-nums; }
.book-table th, .book-table td { padding: 10px 9px; border-top: 1px solid var(--line); }
.book-table th { color: var(--muted); font-size: 13px; font-weight: 580; }
.book-table :is(th, td):first-child { padding-left: 17px; text-align: left; }
.book-table :is(th, td):last-child { padding-right: 17px; }
.book-table td { font-size: 14px; }
.book-table td:first-child span { display: block; color: var(--muted); font-size: 12px; }
.book-table .price { color: var(--mint); font: 660 15px/1.45 var(--mono); }
.orderbook[data-direction=sell] .price { color: var(--rose); }
.book-table tr:last-child td:first-child { border-end-start-radius: 13px; }
.book-table tr:last-child td:last-child { border-end-end-radius: 13px; }
.book-table tbody tr:hover { background: #192534; }
.book-table button { min-width: 58px; font-weight: 680; }
.book-table button[data-direction=buy] { color: var(--mint); background: #1b3737; border-color: #426e63; }
.empty-book { padding: 0 17px 17px; }
.more-book { padding: 8px 17px 13px; border-top: 1px solid var(--line); }
.empty-book p { margin-bottom: 8px; color: var(--muted); }
.market-depth { border-top: 1px solid var(--line); background: #11202b; border-radius: 0 0 13px 13px; }
.market-depth summary { padding-inline: 17px; }
.depth-rows { display: grid; gap: 9px; padding: 0 17px 13px; }
.depth-rows > div { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.depth-rows label { color: var(--muted); font-size: 13px; }
.depth-rows span { grid-column: 3; grid-row: 1; font: 620 13px/1.35 var(--mono); overflow-wrap: anywhere; max-width: 11em; text-align: right; }
.depth-rows progress { grid-column: 2; grid-row: 1; width: 100%; height: 6px; border: 0; border-radius: 6px; background: #263845; appearance: none; }
.depth-ask { --depth-color: #83d3b9; }
.depth-bid { --depth-color: #e696a5; }
.depth-rows progress::-webkit-progress-bar { background: #263845; border-radius: 6px; }
.depth-rows progress::-webkit-progress-value { background: var(--depth-color); border-radius: 6px; }
.depth-rows progress::-moz-progress-bar { background: var(--depth-color); border-radius: 6px; }

.trade-form { display: grid; gap: 9px; padding: 0 17px 17px; }
.trade-form label, .filter { color: var(--muted); font-size: 14px; }
.trade-form input, .trade-form select { width: 100%; }
.trade-form input::placeholder { color: #8fa1b6; }
.fields, .review-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.field { display: grid; gap: 6px; min-width: 0; }
.input-with-button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.quick-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.quick-buttons button { padding-inline: 4px; color: var(--muted); font-size: 13px; }
.quick-buttons button:last-child { color: var(--mint); }
.limit { margin: 0; color: var(--muted); font-size: 14px; }
.limit summary { min-height: 38px; align-content: center; cursor: pointer; }
.limit[open] > label { display: block; margin: 0 0 6px; }
.field-hint, .form-message { margin: 0; font-size: 13px; color: var(--muted); }
.form-message:empty { display: none; }
.form-message[data-error=true] { color: var(--error); }
.quote-sheet { display: grid; gap: 7px; min-width: 0; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--well); font-size: 14px; }
.quote-sheet div { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 10px; }
.quote-sheet dt { color: var(--muted); }
.quote-sheet dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.quote-sheet .emphasis { color: var(--mint); font-weight: 740; }
.quote-sheet div:has(.emphasis) { margin-top: 3px; border-top: 1px solid #324853; padding-top: 8px; }
.create-panel { max-width: 650px; }
.create-panel .segmented button, #fillUnits button { flex: 1; }
.review-list, .records { list-style: none; margin: 0; padding: 0; }
.review-list li { padding-block: 6px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.orders-head { flex-wrap: wrap; }
#bookView, #historyView, .tools { padding: 0 17px 17px; }
.filter { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; }
.filter select { max-width: 100%; }
.records { display: grid; gap: 7px; }
.record { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--well); }
.record strong { display: block; overflow-wrap: anywhere; }
.record p { margin: 2px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.record button { font-size: 14px; }
.record-label { display: inline-block; margin-inline-start: 7px; color: var(--mint); font-size: 13px; font-weight: 520; }
.tools-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.tools p { margin: 8px 0 0; }

dialog { max-height: calc(100dvh - 36px); width: min(100% - 36px, 465px); padding: 0; border: 1px solid #3f5264; border-radius: 14px; background: var(--panel); color: var(--text); overscroll-behavior: contain; }
dialog::backdrop { background: rgba(5, 10, 17, .77); }
body:has(dialog[open]) { overflow: hidden; }
.dialog-content { display: grid; gap: 13px; padding: 16px; }
.dialog-head { justify-content: space-between; align-items: flex-start; gap: 8px; }
.dialog-head button { font-size: 22px; line-height: 1; min-width: 44px; }
dialog .trade-form { padding: 0; }
.review-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

@media (max-width: 820px) {
  .trade-layout { grid-template-columns: minmax(0, 1fr); }
  .sweep-jump { display: inline-flex; align-items: center; min-height: 38px; }
}
@media (max-width: 640px) {
  .otc-page { padding-top: 15px; }
  .market-head { flex-wrap: wrap; gap: 8px 12px; padding: 10px 11px; }
  .pair-identity { gap: 10px; }
  .pair-identity .token-mark { width: 33px; height: 33px; }
  .market-switch { width: 100%; }
  .market-switch button { flex: 1; }
  .market-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .market-metrics > div { padding: 7px 10px; }
  .market-metrics > div:nth-child(odd) { border-inline-start: 0; }
  .market-metrics > div:nth-child(n+3) { border-top: 1px solid #293d4a; }
  .market-metrics dd { margin-top: 2px; }
  .account-bar { gap: 4px 11px; padding: 5px 9px; }
  .account-bar label { gap: 5px; }
  .account-bar select { padding-inline: 7px; }
  .account-bar p { font-size: 13px; }
  .balance-label { display: block; }
  .trade-nav { gap: 4px; }
  .trade-nav button { font-size: 13px; min-height: 53px; padding-inline: 3px; }
  .trade-nav small { font-size: 10px; }
  .trade-help { margin-bottom: 9px; }
  .trade-help dl { grid-template-columns: 1fr; gap: 8px; }
  .panel-head { padding: 14px 12px 10px; }
  .trade-form, .empty-book, #bookView, #historyView, .tools { padding-inline: 12px; }
  .more-book { padding-inline: 12px; }
  .book-table, .book-table tbody { display: block; }
  .book-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .book-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; gap: 6px 8px; border-top: 1px solid var(--line); padding: 9px 12px; }
  .book-table tr td, .book-table tr td:is(:first-child, :last-child) { min-width: 0; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; }
  .book-table .price { grid-column: 2; grid-row: 1; }
  .book-table td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font: 12px/1.4 system-ui, sans-serif; }
  .book-table .book-action { grid-column: 3; grid-row: 1 / span 2; }
  .book-table td:first-child span { font-size: 11px; }
  .market-depth summary, .depth-rows { padding-inline: 12px; }
  .record { padding-inline: 9px; }
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 15px 15px 0 0; }
  .dialog-content { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}
