:root {
  --bg: #031611;
  --panel: rgba(7, 25, 21, 0.95);
  --panel-2: rgba(9, 31, 26, 0.96);
  --border: rgba(84, 150, 129, 0.22);
  --text: #f2f7f5;
  --muted: #8ea9a0;
  --positive: #28d6a3;
  --negative: #ff6f91;
  --accent: #10c78b;
  --grid: rgba(150, 200, 180, 0.08);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(11, 90, 69, 0.35), transparent 26%),
    radial-gradient(circle at left center, rgba(5, 80, 61, 0.14), transparent 20%),
    linear-gradient(180deg, #042019 0%, var(--bg) 32%, #02110d 100%);
  color: var(--text);
}

.page-shell {
  max-width: 1560px;
  margin: 0 auto;
  padding: 34px 26px 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 26px;
}

.hero-copy {
  max-width: 900px;
}

.hero-subtle {
  max-width: 760px;
}

.breadcrumb,
.subtle,
.metric-card small,
.status-pill {
  color: var(--muted);
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1;
  letter-spacing: -0.04em;
  margin-top: 10px;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
  flex-shrink: 0;
}

.status-pill {
  border: 1px solid var(--border);
  background: rgba(15, 48, 40, 0.8);
  padding: 10px 14px;
  border-radius: 999px;
  text-align: center;
}

.timeframe-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  background: rgba(8, 26, 21, 0.92);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}

.timeframe-switch button {
  appearance: none;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 11px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s ease;
  font-weight: 600;
  white-space: nowrap;
}

.timeframe-switch button.active {
  color: #081510;
  background: linear-gradient(180deg, #3bf1bf, #0fc78b);
}

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

.metric-card,
.panel {
  background: linear-gradient(180deg, rgba(7, 25, 21, 0.98), rgba(4, 18, 15, 0.98));
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 132px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric-card .label {
  font-size: 14px;
  color: var(--muted);
}

.metric-card strong {
  font-size: clamp(24px, 2.2vw, 42px);
  line-height: 1;
  letter-spacing: -0.03em;
  word-break: break-word;
}

.layout-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr);
  margin-bottom: 18px;
}

.lower-grid {
  grid-template-columns: 1fr 1fr;
}

.panel {
  padding: 18px;
}

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

.panel-header h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

.legend {
  font-size: 13px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.positive {
  background: var(--positive);
}

.chart-wrapper {
  position: relative;
  height: 360px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(2, 10, 8, 0.5), rgba(2, 14, 10, 0.2));
  overflow: hidden;
}

#equityChart {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.hidden {
  display: none;
}

.event-list {
  max-height: 360px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.event-item {
  border: 1px solid rgba(84, 150, 129, 0.14);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(8, 22, 19, 0.76);
}

.event-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.event-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(84, 150, 129, 0.16);
}

.event-tag.long,
.pnl.positive,
.regime-positive {
  color: var(--positive);
}

.event-tag.short,
.pnl.negative,
.regime-negative {
  color: var(--negative);
}

.table-wrap {
  overflow: auto;
  max-height: 500px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(84, 150, 129, 0.12);
  white-space: nowrap;
}

th {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.side-pill.long {
  background: rgba(40, 214, 163, 0.14);
  color: var(--positive);
}

.side-pill.short {
  background: rgba(255, 111, 145, 0.12);
  color: var(--negative);
}

.empty-row td {
  color: var(--muted);
  text-align: center;
}

code {
  background: rgba(10, 28, 23, 0.9);
  padding: 2px 8px;
  border-radius: 8px;
}

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

  .layout-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .page-shell {
    padding: 22px 14px 34px;
  }

  .hero {
    flex-direction: column;
    gap: 16px;
  }

  .hero-actions {
    align-items: stretch;
    width: 100%;
  }

  .status-pill {
    width: 100%;
  }

  .timeframe-switch {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .timeframe-switch::-webkit-scrollbar {
    display: none;
  }

  .timeframe-switch button {
    flex: 1 0 auto;
  }

  .panel,
  .metric-card {
    border-radius: 18px;
  }

  .chart-wrapper {
    height: 300px;
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: clamp(28px, 9vw, 42px);
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 104px;
    gap: 8px;
  }

  .metric-card strong {
    font-size: clamp(22px, 7vw, 34px);
  }

  .panel {
    padding: 14px;
  }

  .panel-header,
  .compact-header,
  .event-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-header h2 {
    font-size: 20px;
  }

  .chart-wrapper {
    height: 230px;
  }

  .event-list,
  .table-wrap {
    max-height: none;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    border: 1px solid rgba(84, 150, 129, 0.14);
    background: rgba(8, 22, 19, 0.76);
    border-radius: 16px;
    padding: 10px 12px;
  }

  td {
    border: 0;
    padding: 8px 0;
    white-space: normal;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 42%;
  }

  td > strong,
  td > span,
  td > div,
  td {
    overflow-wrap: anywhere;
  }

  .empty-row td,
  .empty-row td::before {
    display: block;
    text-align: center;
    flex: unset;
  }

  .empty-row td::before {
    content: none;
  }
}

@media (max-width: 420px) {
  .page-shell {
    padding: 18px 10px 26px;
  }

  .timeframe-switch {
    gap: 2px;
    padding: 3px;
  }

  .timeframe-switch button {
    padding: 10px 12px;
    font-size: 13px;
  }

  .chart-wrapper {
    height: 200px;
  }

  td::before {
    flex-basis: 38%;
  }
}
