@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Source+Sans+3:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f7f5f1;
  --panel: #ffffff;
  --panel-border: #e3ded6;
  --text: #1f1c18;
  --muted: #6d655a;
  --accent: #9f4b3a;
  --accent-muted: rgba(159, 75, 58, 0.12);
  --positive: #2a7d4f;
  --negative: #b63a3a;
  --font-body: "Source Sans 3", "Gill Sans", "Trebuchet MS", sans-serif;
  --font-title: "Fraunces", "Baskerville", "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2.5rem clamp(1rem, 4vw, 3.5rem);
  background:
    radial-gradient(circle at 15% 0%, rgba(159, 75, 58, 0.06), transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(247, 245, 241, 0.92)),
    repeating-linear-gradient(90deg, rgba(31, 26, 20, 0.025) 0 1px, transparent 1px 42px),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  font-size: 16.5px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 3rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--panel-border);
}

.header-identity {
  flex: 1 1 240px;
}

.header-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.75rem;
  align-items: stretch;
}

.header-stat {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 1.75rem 0.6rem 0;
  border-right: 1px solid var(--panel-border);
}

.header-stat:last-child {
  padding-right: 0;
  border-right: none;
}

.header-stat-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.header-stat-value {
  font-family: var(--font-title);
  font-size: 1.25rem;
  line-height: 1;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 0.35rem;
  font-weight: 600;
}

h1 {
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  margin: 0;
  font-family: var(--font-title);
  letter-spacing: 0.02em;
}

.subtitle {
  max-width: 36rem;
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}


main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.85rem;
  padding: 1.6rem;
  box-shadow: 0 16px 40px rgba(31, 26, 20, 0.08);
  animation: rise-in 0.65s ease both;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.panel-subtitle {
  color: var(--muted);
  margin: 0;
}


.mana-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  object-fit: contain;
  vertical-align: -2px;
  margin-right: 0.35rem;
}

.agent-details {
  min-height: 200px;
  --detail-accent: var(--accent);
  --detail-accent-muted: var(--accent-muted);
}

.empty-state {
  color: var(--muted);
  text-align: center;
  margin: 2rem 0;
}

.loading-state {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 1.5rem auto;
  padding: 0.6rem 1rem;
  border: 1px dashed var(--panel-border);
  border-radius: 999px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(31, 26, 20, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.loading-state {
  justify-content: center;
}

.detail-card {
  border: 1px solid var(--panel-border);
  border-radius: 0.85rem;
  padding: 1.1rem;
  background: rgba(255, 255, 255, 0.6);
}

.value-card {
  margin-bottom: 0.9rem;
  padding: 1rem 1.1rem 1.05rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.72)),
    var(--panel);
}

.value-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.65rem;
}

.value-card-header h3 {
  margin: 0;
  font-family: var(--font-title);
}

.value-card-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.value-chart-shell {
  border: 1px solid var(--panel-border);
  border-radius: 0.7rem;
  padding: 0.65rem 0.7rem 0.45rem;
  background: rgba(255, 255, 255, 0.78);
}

.value-chart {
  width: 100%;
  height: auto;
  display: block;
}

.value-grid-line {
  stroke: var(--panel-border);
  stroke-dasharray: 4 5;
  stroke-width: 1;
}

.value-axis-text {
  fill: var(--muted);
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.value-area {
  /* fill set via SVG linearGradient in JS */
}

.value-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.value-point {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 1.7;
}

.value-axis-dates {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0 0.2rem;
}

.tabbed-card {
  padding: 0;
  overflow: hidden;
}

.tab-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 1.2rem;
  padding: 1.1rem 1.1rem 0;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.72);
}

.tab-header h3 {
  margin: 0;
  font-family: var(--font-title);
}

.tab-buttons {
  display: inline-flex;
  gap: 0.35rem;
  align-items: flex-end;
  padding: 0 0.4rem;
  margin-bottom: -1px;
  position: relative;
  isolation: isolate;
}

.tab-button {
  border: none;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.5rem 1.1rem 0.55rem;
  border-radius: 0.75rem 0.75rem 0 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  border: 1px solid var(--panel-border);
  border-bottom-color: var(--panel-border);
  position: relative;
  top: 0;
  transform: translateY(1px);
  z-index: 1;
}

.tab-button.active {
  background: var(--panel);
  color: var(--accent);
  transform: translateY(0);
  border-bottom-color: var(--panel);
  box-shadow: 0 -6px 16px rgba(31, 26, 20, 0.08);
  z-index: 3;
}

.tab-panels {
  padding: 1rem 1.1rem 1.2rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.detail-card.accent {
  border-color: var(--detail-accent-soft, var(--panel-border));
  box-shadow: 0 0 18px rgba(31, 26, 20, 0.08);
}

.agent-details h3 {
  color: var(--detail-accent-strong, var(--text));
  opacity: 0.9;
}

.positions-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.positions-list li {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(160px, 2fr) repeat(2, minmax(80px, 1fr));
  gap: 0.75rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.85rem;
  align-items: center;
}

.positions-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.positions-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.positions-head {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(160px, 2fr) repeat(2, minmax(80px, 1fr));
  gap: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--muted);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--panel-border);
}

.position-title {
  margin: 0;
  font-weight: 600;
  line-height: 1.4;
}

.position-meta {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.position-market {
  min-width: 0;
}

.position-cell {
  display: grid;
  gap: 0.2rem;
  font-size: 0.9rem;
  color: var(--text);
}

.cell-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.cell-value {
  font-weight: 600;
}

.cell-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.trades-table {
  width: 100%;
  border-collapse: collapse;
}

.trades-table th,
.trades-table td {
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--panel-border);
}

.trades-table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.16em;
}

.trades-table tbody tr:nth-child(odd) {
  background: rgba(31, 26, 20, 0.025);
}

.trades-table td a {
  color: var(--accent);
  text-decoration: none;
}

.trade-reason {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.pill.source-pill {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--panel-border);
  text-decoration: none;
  letter-spacing: 0.04em;
}

.pill.tool-pill {
  background: var(--agent-accent-soft, rgba(31, 26, 20, 0.08));
  color: var(--text);
  border: 1px solid var(--panel-border);
  letter-spacing: 0.08em;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.pill.open {
  background: rgba(181, 72, 58, 0.12);
  color: var(--accent);
}

.pill.executed {
  background: rgba(42, 125, 79, 0.15);
  color: var(--positive);
}

.pill.skipped {
  background: rgba(170, 146, 82, 0.16);
  color: #7a5f1a;
}

.pill.failed {
  background: rgba(182, 58, 58, 0.15);
  color: var(--negative);
}

.pill.resolved {
  background: rgba(42, 125, 79, 0.15);
  color: var(--positive);
}

.pill.loss {
  background: rgba(182, 58, 58, 0.15);
  color: var(--negative);
}

/* ── Last-run badge ── */
.last-run-badge {
  display: inline-block;
  margin-left: 0.55rem;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--accent-muted);
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  vertical-align: middle;
}

/* ── Stats strip ── */
.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.stats-chip {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 1rem;
  border-radius: 0.65rem;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  min-width: 80px;
}

.stats-chip-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
}

.stats-chip-value {
  font-family: var(--font-title);
  font-size: 1.05rem;
  line-height: 1;
  color: var(--text);
}

.stats-chip-value.positive { color: var(--positive); }
.stats-chip-value.negative { color: var(--negative); }

/* ── Positions: left-border row accent ── */
.positions-list li.row-positive {
  border-left: 3px solid var(--positive);
  padding-left: 0.65rem;
}

.positions-list li.row-negative {
  border-left: 3px solid var(--negative);
  padding-left: 0.65rem;
}

/* ── Probability combined bar ── */
.prob-bar-cell {
  padding: 0.1rem 0;
}

.prob-bar-combined {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.prob-bar-track-v2 {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--panel-border);
  overflow: visible;
}

.prob-bar-fill-v2 {
  height: 100%;
  border-radius: 999px;
  min-width: 2px;
  transition: width 0.4s ease;
}

/* vertical marker line at entry probability */
.prob-bar-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  background: var(--text);
  border-radius: 1px;
  transform: translateX(-50%);
  opacity: 0.45;
}

.prob-bar-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  line-height: 1;
  gap: 0.3rem;
}

.prob-bar-entry,
.prob-bar-current {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  white-space: nowrap;
}

.prob-bar-entry {
  color: var(--muted);
}

.prob-bar-current {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.prob-bar-sublabel {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  opacity: 0.7;
}

.prob-bar-arrow {
  flex: 1;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Chart hover tooltip ── */
.chart-tooltip-line {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.chart-tooltip-dot {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2;
  pointer-events: none;
}

.chart-tooltip-box {
  fill: var(--text);
  rx: 5;
  ry: 5;
  pointer-events: none;
}

.chart-tooltip-text {
  fill: #fff;
  font-family: var(--font-body);
  font-size: 11px;
  pointer-events: none;
}

/* ── Trade cards ── */
.trades-list {
  display: grid;
  gap: 0.85rem;
}

.trade-card {
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.6);
}

.trade-card-title {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.4;
}

.trade-card-title a {
  color: inherit;
  text-decoration: none;
}

.trade-card-title a:hover {
  text-decoration: underline;
}

.trade-card-reason {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.trade-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  padding-top: 0.5rem;
  border-top: 1px solid var(--panel-border);
}

.trade-card-meta strong {
  color: var(--text);
  font-weight: 600;
}

.trade-card-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.trade-card-pill-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
  margin-right: 0.2rem;
  white-space: nowrap;
}

/* ── Tool pill tooltip ── */
.pill.tool-pill {
  position: relative;
  cursor: default;
}

.pill.tool-pill[title]::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.45;
  padding: 0.4rem 0.65rem;
  border-radius: 0.45rem;
  white-space: normal;
  width: max-content;
  max-width: 240px;
  box-shadow: 0 4px 14px rgba(31, 26, 20, 0.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.pill.tool-pill[title]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.pill.tool-pill[title]:hover::after,
.pill.tool-pill[title]:hover::before {
  opacity: 1;
}

.page-footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.panel:nth-of-type(2) {
  animation-delay: 0.08s;
}


@media (max-width: 640px) {
  body {
    padding: 1.5rem 1rem;
  }

  .value-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .value-card-stats {
    justify-content: flex-start;
  }

  .positions-head {
    display: none;
  }

  .positions-list li {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem 1rem;
  }

  .position-market {
    grid-column: 1 / -1;
  }

  .prob-bar-cell {
    grid-column: 1 / -1;
  }
}
