/* Histórico — alinhado ao Painel de Trading */

.hist-kpis {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.hist-kpis[hidden] { display: none !important; }

.hist-kpis::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold), rgba(226, 179, 74, 0.15));
  z-index: 1;
}

.hist-kpi {
  min-width: 0;
  padding: 0.9rem 1rem;
  border-right: 1px solid var(--line);
}

.hist-kpi:last-child { border-right: none; }

.hist-kpi .label {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.hist-kpi .value {
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-kpi .hint {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-panel {
  position: relative;
}

.hist-panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, rgba(226, 179, 74, 0.55), transparent 70%);
  pointer-events: none;
  z-index: 2;
}

.table-scroll {
  max-height: none;
  overflow-x: auto;
}

.hist-table {
  font-size: 0.8rem;
}

.hist-table th {
  position: sticky;
  top: 0;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  padding: 0.7rem 0.85rem;
  background: #121920;
}

.hist-table td {
  padding: 0.72rem 0.85rem;
  vertical-align: middle;
  border-bottom: 1px solid rgba(140, 160, 185, 0.08);
}

.hist-table tbody tr {
  transition: background 0.15s ease;
}

.hist-table tbody tr:hover td {
  background: rgba(226, 179, 74, 0.04);
}

.hist-table tbody tr.is-win td:first-child {
  box-shadow: inset 2px 0 0 var(--good);
}

.hist-table tbody tr.is-loss td:first-child {
  box-shadow: inset 2px 0 0 var(--bad);
}

.hist-table .pair {
  font-family: var(--display);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.hist-table .when {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}

.hist-table .num {
  font-family: var(--mono);
}

.hist-table .pnl-cell {
  font-family: var(--mono);
  font-weight: 600;
}

.reason-pill {
  display: inline-flex;
  align-items: center;
  max-width: 11rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reason-pill.win {
  color: var(--good);
  border-color: rgba(78, 201, 168, 0.28);
  background: rgba(78, 201, 168, 0.08);
}

.reason-pill.loss {
  color: var(--bad);
  border-color: rgba(217, 123, 104, 0.3);
  background: rgba(217, 123, 104, 0.08);
}

.muted-unit {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.trades-cards {
  display: none;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem;
}

.trade-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 0.85rem 0.9rem 0.85rem 1rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

.trade-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--muted);
}

.trade-card.is-win::before { background: var(--good); }
.trade-card.is-loss::before { background: var(--bad); }

.trade-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.trade-card .pair {
  font-family: var(--display);
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.trade-card .pnl {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.05rem;
}

.trade-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.85rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.trade-card-meta .k {
  display: block;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.12rem;
  opacity: 0.85;
}

.trade-card-meta strong {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 550;
  font-size: 0.78rem;
}

.trade-card-foot {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
}

.empty[hidden] { display: none !important; }

@media (max-width: 900px) {
  .hist-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-kpi:nth-child(2) { border-right: none; }
  .hist-kpi:nth-child(1),
  .hist-kpi:nth-child(2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 640px) {
  .trades-table-wrap { display: none; }
  .trades-cards { display: flex; }
  .hist-kpi { padding: 0.75rem 0.85rem; }
}
