/*
 * Trader space: account cards, calm rows for ended accounts, meters, pills and the action buttons of both.
 * An active card is an instrument: identity, equity, three meters. Its left edge stays neutral until a limit gets tight.
 */
.sp-cards, .sp-rows { display: grid; gap: 12px; }
.sp-rows { gap: 8px; }

/* ---------- active card ---------- */
.sp-card {
  --edge: var(--line-strong);
  position: relative; display: grid; gap: 16px 32px; padding: 20px 22px 16px 24px;
  grid-template-columns: minmax(180px, 1fr) minmax(170px, 0.8fr) minmax(300px, 2fr);
  grid-template-areas: "id eq meters" "actions actions meters"; grid-template-rows: auto 1fr;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.045), 0 22px 44px -34px rgb(0 0 0 / 0.95);
  transition: border-color var(--t-fast), box-shadow var(--t);
}
.sp-card::before {
  content: ""; position: absolute; left: -1px; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--edge); opacity: 0.55;
}
.sp-card[data-state="tight"] { --edge: var(--warn); }
.sp-card[data-state="critical"], .sp-card[data-state="touched"] { --edge: var(--down); }
.sp-card[data-state="tight"]::before, .sp-card[data-state="critical"]::before, .sp-card[data-state="touched"]::before {
  opacity: 1; box-shadow: 0 0 16px -2px var(--edge);
}
.sp-card-id { grid-area: id; display: grid; gap: 8px; align-content: start; min-width: 0; }
.sp-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.sp-card-meta { margin: 0; font-size: 12px; color: var(--mute); }
.sp-card-eq { grid-area: eq; display: grid; gap: 4px; align-content: start; justify-items: start; min-width: 0; }
.sp-card-label { margin: 0; font-size: 10.5px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }
.sp-card-eqval { margin: 0; font-size: 29px; font-weight: 650; line-height: 1.1; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.sp-pnl { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--mute); }
.sp-pnl[data-tone="up"] { color: var(--up); }
.sp-pnl[data-tone="down"] { color: var(--down); }
.sp-card-meters { grid-area: meters; display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 18px 22px; align-content: start; }
.sp-card-note { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--mute); }
.sp-card-actions { grid-area: actions; display: flex; flex-wrap: wrap; align-content: flex-end; gap: 8px; }
.sp-card-actions .btn { gap: 7px; }

/* ---------- meters ---------- */
.sp-meter { display: grid; gap: 7px; min-width: 0; }
.sp-meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.sp-meter-name { min-width: 0; font-size: 10.5px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-meter-word { font-size: 11px; font-weight: 700; white-space: nowrap; }
.sp-meter[data-status="ok"] .sp-meter-word { color: var(--up); }
.sp-meter[data-status="tight"] .sp-meter-word { color: var(--warn); }
.sp-meter[data-status="critical"] .sp-meter-word, .sp-meter[data-status="touched"] .sp-meter-word { color: var(--down); }
.sp-meter[data-id="target"] .sp-meter-word { color: var(--acc); }
.sp-meter[data-id="target"] .meter { --meter-color: var(--acc); }
.sp-meter .meter { height: 7px; margin: 0; }
.sp-meter-text { margin: 0; font-size: 12.5px; color: var(--text); }

/* ---------- pills ---------- */
.sp-pill[data-kind="failed"] { color: var(--down); background: var(--down-soft); border-color: transparent; }
.sp-pill[data-kind="closed"] { color: var(--mute); background: var(--surface-3); border-color: var(--line-2); }
.sp-pill[data-kind="passed"] { color: var(--acc); background: var(--acc-soft); }

/* ---------- ended rows ---------- */
.sp-row {
  position: relative; display: grid; align-items: center; gap: 12px 28px; padding: 14px 20px 14px 22px;
  grid-template-columns: minmax(230px, 1.3fr) minmax(0, 1.4fr) auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.sp-row::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--line-strong); opacity: 0.5; }
.sp-row[data-kind="failed"]::before { background: var(--down); opacity: 0.7; }
.sp-row[data-kind="passed"]::before { background: var(--acc); opacity: 0.8; }
.sp-row-id { display: grid; gap: 6px; min-width: 0; }
.sp-row-reason { margin: 0; font-size: 12px; color: var(--mute); }
.sp-row-figs { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0; }
.sp-fig dt { font-size: 10.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.sp-fig dd { margin: 3px 0 0; font-size: 14px; font-weight: 600; }
.sp-fig dd[data-tone="up"] { color: var(--up); }
.sp-fig dd[data-tone="down"] { color: var(--down); }
.sp-row .sp-card-note { grid-column: 1 / 3; }
.sp-row .sp-card-actions { grid-area: auto; padding: 0; border: 0; justify-content: flex-end; }

@media (hover: hover) {
  .sp-card:hover { border-color: var(--line-strong); }
  .sp-row:hover { border-color: var(--line-2); background: var(--surface-2); }
}

/* ---------- narrower: the meters go under the identity ---------- */
@media (max-width: 1099px) {
  .sp-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "id eq" "meters meters" "actions actions"; grid-template-rows: auto; gap: 16px 24px; }
  .sp-card-actions { padding-top: 14px; border-top: 1px solid var(--line); justify-content: flex-end; }
  .sp-row { grid-template-columns: minmax(0, 1fr) auto; }
  .sp-row-figs { grid-column: 1 / -1; grid-row: 2; }
  .sp-row .sp-card-actions { grid-column: 2; grid-row: 1; }
  .sp-row .sp-card-note { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .sp-card { grid-template-columns: minmax(0, 1fr); grid-template-areas: "id" "eq" "meters" "actions"; padding: 18px 16px 14px 20px; }
  .sp-card-eqval { font-size: 30px; }
  .sp-card-meters { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .sp-card-actions .btn { flex: 1 1 0; min-height: 44px; }
  .sp-card-actions .btn.primary { flex-basis: 100%; }
  .sp-row { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 14px 20px; }
  .sp-row .sp-card-actions { grid-column: 1; grid-row: auto; justify-content: stretch; }
  .sp-row .sp-card-actions .btn { flex: 1 1 0; min-height: 44px; }
  .sp-row-figs { grid-row: auto; gap: 8px 22px; }
}
