/* Trade history — Trades + "Orders placed by SODA" tabs and the trade detail page
   (frontend/js/trade-history.js), ONE component on the live broker account page and the
   SODA paper account page. Alex approved the final mockup 10/16
   (soda-audit/trade-history/mockup.html). Tokens only (css/tokens.css): P/L colours for
   P/L numbers only; text >= 12px; taps >= 44px; no sideways scroll at 390px. */
.th-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ds-border); overflow-x: auto; margin: 4px 0 2px; }
.th-tab { min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; font: inherit; font-size: 13px;
  color: var(--ds-muted); background: none; border: 0; border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; }
.th-tab:hover { color: var(--ds-text); }
.th-tab.on { color: var(--ds-text); font-weight: 600; border-bottom-color: var(--ds-text); }

.th { display: grid; gap: 14px; min-width: 0; font-variant-numeric: tabular-nums; color: var(--ds-text); }
.th-k { font-size: 12px; color: var(--ds-label); letter-spacing: .04em; text-transform: uppercase; font-weight: 500; }
.th-s { font-size: 12px; color: var(--ds-muted); }
.th-muted { color: var(--ds-muted); }
.th-up { color: var(--ds-pnl-up); }
.th-down { color: var(--ds-pnl-down); }
.th-note { font-size: 12px; color: var(--ds-muted); text-align: right; margin-bottom: -6px; }
.th-h3 { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ds-label); margin: 0; }

.th-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.th-stat { border: 1px solid var(--ds-border); border-radius: var(--ds-r-md); padding: 10px 12px; background: var(--ds-surface); min-width: 0; }
.th-stat .th-v { font-size: 18px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.th-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.th-f { display: grid; gap: 4px; min-width: 0; }
.th-f select { min-height: 44px; border: 1px solid var(--ds-field-edge); background: var(--ds-surface); color: var(--ds-text);
  border-radius: var(--ds-r-sm); padding: 0 10px; min-width: 130px; font: inherit; }
.th-seg { display: inline-flex; border: 1px solid var(--ds-field-edge); border-radius: var(--ds-r-sm); overflow: hidden; }
.th-seg button { min-height: 44px; min-width: 44px; padding: 0 12px; border: 0; background: transparent; cursor: pointer;
  color: var(--ds-muted); font: inherit; font-size: 13px; }
.th-seg button + button { border-left: 1px solid var(--ds-border); }
.th-seg button.on { background: var(--ds-hover); color: var(--ds-text); font-weight: 600; }
.th-btn { min-height: 44px; padding: 0 16px; border-radius: var(--ds-r-md); border: 1px solid var(--ds-border-strong);
  background: transparent; color: var(--ds-text); cursor: pointer; font: inherit; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px; }
.th-btn:hover { background: var(--ds-hover); }
.th-grow { flex: 1; }

.th-card { background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-r-lg); padding: 16px;
  display: grid; gap: 12px; min-width: 0; align-content: start; }
.th-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.th-tbl th { text-align: left; font-size: 12px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ds-label); padding: 8px 10px; border-bottom: 1px solid var(--ds-border); white-space: nowrap; }
.th-tbl td { padding: 10px; border-bottom: 1px solid var(--ds-border); vertical-align: middle; }
.th-tbl tr.th-row { cursor: pointer; }
.th-tbl tr.th-row:hover td, .th-tbl tr.th-row:focus-visible td { background: var(--ds-hover); }
.th-tbl tr.th-row:focus-visible { outline: none; }
.th-tbl .th-r { text-align: right; white-space: nowrap; }
.th-c1 { font-weight: 600; }
.th-sub { display: block; font-size: 12px; color: var(--ds-muted); font-weight: 400; }
.th-badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--ds-r-pill);
  border: 1px solid var(--ds-border-strong); color: var(--ds-text); white-space: nowrap; }
.th-badge.th-na { border-style: dashed; color: var(--ds-muted); font-weight: 500; }
.th-pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--ds-r-pill);
  border: 1px solid var(--ds-border-strong); color: var(--ds-muted); white-space: nowrap; }
.th-more { display: flex; justify-content: center; padding-top: 6px; }
.th-empty { text-align: center; padding: 36px 14px; color: var(--ds-muted); border: 1px dashed var(--ds-border-strong); border-radius: var(--ds-r-md); }
.th-empty b { color: var(--ds-text); font-size: 16px; font-weight: 600; }
.th-msg { padding: 24px 14px; color: var(--ds-muted); font-size: 13px; text-align: center; }

/* the trade detail page hides the account page's own head (paper page; live: css/live-account.css) */
#paper-account-detail.pa-th-detail .pa-head-block, #paper-account-detail.pa-th-detail > .th-tabs { display: none; }

/* detail */
.th-back { scroll-margin-top: 180px; display: inline-flex; align-items: center; min-height: 44px; font: inherit; font-size: 13px; color: var(--ds-muted);
  background: none; border: 0; padding: 0; cursor: pointer; width: max-content; }
.th-back:hover { color: var(--ds-text); }
.th-hero { display: flex; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; align-items: flex-start; }
.th-hero .th-t { font-size: 20px; font-weight: 600; }
.th-hero .th-pl { font-size: 28px; font-weight: 700; text-align: right; }
.th-hero-r { text-align: right; }
.th-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.th-sumline { font-size: 14px; color: var(--ds-text); padding: 2px 0; }
.th-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.th-kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 12px; font-size: 13px; }
.th-kv > div:nth-child(odd) { color: var(--ds-muted); }
.th-kv .th-kvv { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.th-mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.th-mini th, .th-mini td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--ds-border); }
.th-mini th { font-size: 12px; font-weight: 500; color: var(--ds-label); text-transform: uppercase; letter-spacing: .04em; }
.th-mini .th-r { text-align: right; }
.th-lines { display: grid; gap: 8px; font-size: 13px; }
.th-tl { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--ds-border); display: grid; gap: 12px; }
.th-tl li { position: relative; display: grid; grid-template-columns: 112px 1fr; gap: 4px 12px; font-size: 13px; min-width: 0; }
.th-tl li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ds-surface); border: 2px solid var(--ds-border-strong); }
.th-tl li.th-key::before { background: var(--ds-text); border-color: var(--ds-text); }
.th-tl .th-tt { color: var(--ds-muted); white-space: nowrap; }
.th-tl .th-x { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .th-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .th-cols { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .th-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .th-stat .th-v { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .th-filters .th-f, .th-f select { width: 100%; }
  .th-filters .th-f { flex: 1 1 100%; }
  .th-filters .th-seg { width: 100%; }
  .th-filters .th-seg button { flex: 1; }
  .th-btn.th-csv { width: 100%; justify-content: center; }
  .th-tbl thead { display: none; }
  .th-tbl, .th-tbl tbody, .th-tbl tr, .th-tbl td { display: block; width: 100%; }
  .th-tbl tr.th-row, .th-tbl.th-orders tr { border: 1px solid var(--ds-border); border-radius: var(--ds-r-md); padding: 10px 12px;
    margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; background: var(--ds-surface); }
  .th-tbl td { border: 0; padding: 0; }
  .th-tbl td.th-mfull { grid-column: 1 / -1; }
  .th-tbl td.th-r { text-align: right; }
  .th-tbl td.th-hidem { display: none; }
  .th-card.th-list { padding: 10px; }
  .th-kv { grid-template-columns: 1fr; gap: 2px 0; }
  .th-kv > div:nth-child(even) { margin-bottom: 8px; }
  .th-tl li { grid-template-columns: 1fr; }
  .th-hero-r, .th-hero .th-pl { text-align: left; }
  .th-hero .th-t { font-size: 18px; }
}
