:root {
  color-scheme: dark;
  --bg: #12081e;
  --panel: rgba(33, 13, 54, 0.92);
  --panel-strong: rgba(16, 7, 27, 0.96);
  --line: rgba(173, 125, 245, 0.22);
  --line-strong: rgba(181, 255, 150, 0.34);
  --text: #f6ebff;
  --muted: #c9b4e4;
  --accent: #b5ff96;
  --violet: #9e6bff;
  --success: #84f8c0;
  --danger: #ff9bb0;
  --warning: #ffe18b;
  --shadow: 0 24px 80px rgba(4, 0, 9, 0.55);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --mono: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(181, 255, 150, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(158, 107, 255, 0.18), transparent 34%),
    linear-gradient(180deg, #1e082e 0%, #12081e 45%, #0b0412 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(124, 255, 152, 0.02) 1px, transparent 1px);
  background-size: 100% 6px;
  opacity: 0.25;
}

.history-shell {
  width: min(1520px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.history-hero,
.panel,
.metric-card,
.insight-panel,
.anchor-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(39, 16, 63, 0.92), rgba(20, 7, 33, 0.94));
  box-shadow: var(--shadow);
}

.history-hero {
  padding: 28px;
  display: grid;
  grid-template-columns: 1.35fr minmax(320px, 0.95fr);
  gap: 24px;
}

.eyebrow,
.panel-label {
  margin: 0 0 8px;
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  font-size: clamp(1.9rem, 3vw, 3.2rem);
}

h2 {
  font-size: 1.38rem;
}

.hero-text,
.meta-caption,
.inline-note,
.panel p,
.chart-empty {
  color: var(--muted);
}

.history-hero__meta {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill,
.meta-pill,
.balance-pill,
.ghost-button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  font: inherit;
}

.status-pill {
  background: rgba(132, 248, 192, 0.14);
  color: var(--success);
}

.meta-pill,
.balance-pill,
.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.balance-pill strong,
.metric-card strong,
.insight-stat strong {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.ghost-button {
  cursor: pointer;
  text-decoration: none;
}

.insight-panel {
  margin-top: 20px;
  padding: 22px 24px;
}

.insight-panel__copy {
  display: grid;
  gap: 10px;
}

.insight-dialog {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(181, 255, 150, 0.18);
  background: linear-gradient(180deg, rgba(181, 255, 150, 0.08), rgba(158, 107, 255, 0.08));
}

.insight-dialog__lead {
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 700;
}

.insight-dialog__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.insight-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.metrics-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 18px;
  min-height: 118px;
}

.metric-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  font-size: clamp(1.2rem, 1.8vw, 2rem);
  color: var(--accent);
}

.history-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.panel {
  padding: 22px;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-shell {
  min-height: 240px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 216px;
}

.table-shell {
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

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

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(15, 6, 24, 0.96);
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.outcome-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.outcome-pill.hit {
  background: rgba(132, 248, 192, 0.14);
  color: var(--success);
}

.outcome-pill.miss {
  background: rgba(255, 155, 176, 0.14);
  color: var(--danger);
}

.anchor-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
}

.anchor-card {
  padding: 18px;
  border-radius: var(--radius-lg);
}

.anchor-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.anchor-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(181, 255, 150, 0.18);
  background: rgba(181, 255, 150, 0.08);
  color: var(--text);
  font-weight: 700;
}

.anchor-note-list {
  display: grid;
  gap: 10px;
}

.anchor-note-list p,
.insight-dialog p {
  margin: 0;
  line-height: 1.55;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .history-grid,
  .anchor-grid,
  .history-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .history-shell {
    width: min(100%, calc(100% - 20px));
    margin: 14px auto 28px;
  }

  .history-hero,
  .panel,
  .metric-card,
  .insight-panel {
    padding: 18px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
