:root {
  color-scheme: dark;
  --bg: #080b0f;
  --surface: rgba(17, 23, 31, 0.92);
  --surface-2: rgba(25, 34, 44, 0.94);
  --surface-3: rgba(32, 42, 52, 0.98);
  --line: rgba(211, 222, 231, 0.16);
  --line-strong: rgba(211, 222, 231, 0.32);
  --text: #eef5f3;
  --muted: #9fb0b3;
  --soft: #ced9d7;
  --green: #4fd18b;
  --cyan: #5ab7d8;
  --amber: #e1b65a;
  --rose: #e96d83;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(130deg, rgba(79, 209, 139, 0.08), transparent 28%),
    linear-gradient(180deg, #080b0f 0%, #10161c 46%, #090d11 100%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

.drawdown-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.drawdown-header,
.metric-grid,
.chart-section,
.workspace-grid,
.source-panel {
  margin-bottom: 18px;
}

.monitor-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.monitor-nav a,
.tab-row button,
.icon-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 23, 31, 0.92);
  color: var(--soft);
  text-decoration: none;
}

.monitor-nav a {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
}

.monitor-nav a:hover,
.tab-row button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 18px;
  align-items: stretch;
}

.title-copy,
.live-panel,
.metric-card,
.chart-section,
.table-panel,
.alert-panel,
.source-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.title-copy {
  padding: 22px;
}

.kicker,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(31px, 5.2vw, 58px);
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.headline {
  max-width: 920px;
  margin-bottom: 0;
  color: var(--soft);
  font-size: 16px;
  line-height: 1.72;
}

.live-panel {
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 18px;
}

.live-panel span,
.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.live-panel strong {
  font-size: 34px;
  line-height: 1;
}

.icon-button {
  cursor: pointer;
  width: fit-content;
  padding: 0 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  min-width: 0;
  padding: 16px;
}

.metric-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.metric-symbol {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 14px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.metric-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--soft);
  font-size: 12px;
}

.pill.green {
  color: var(--green);
}

.pill.cyan {
  color: var(--cyan);
}

.pill.amber {
  color: var(--amber);
}

.pill.rose {
  color: var(--rose);
}

.chart-section,
.table-panel,
.alert-panel,
.source-panel {
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tab-row button {
  cursor: pointer;
  padding: 0 12px;
  font-size: 13px;
}

.tab-row button.active {
  border-color: rgba(79, 209, 139, 0.62);
  color: var(--green);
  background: rgba(79, 209, 139, 0.1);
}

.chart-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)),
    #0b1015;
}

#drawdown-chart {
  display: block;
  width: 100%;
  height: min(58vh, 520px);
  min-height: 340px;
}

.axis text,
.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.axis line,
.grid-line {
  stroke: rgba(211, 222, 231, 0.14);
}

.zero-line {
  stroke: rgba(211, 222, 231, 0.35);
  stroke-width: 1.2;
}

.drawdown-line {
  fill: none;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  font-size: 13px;
}

.legend-swatch {
  width: 18px;
  height: 3px;
  border-radius: 99px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 18px;
  align-items: stretch;
}

.workspace-grid > * {
  min-width: 0;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid rgba(211, 222, 231, 0.1);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

tr:last-child td {
  border-bottom: 0;
}

.alert-list,
.source-grid {
  display: grid;
  gap: 10px;
}

.alert-card,
.source-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.alert-card strong,
.source-card strong {
  display: block;
  margin-top: 6px;
  font-size: 16px;
}

.alert-card p,
.source-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.62;
}

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

.source-card a {
  color: var(--cyan);
  text-decoration: none;
}

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

.error-line {
  color: var(--rose);
}

@media (max-width: 1080px) {
  .hero-grid,
  .metric-grid,
  .workspace-grid,
  .source-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
  }

  .tab-row {
    justify-content: flex-start;
  }

  table {
    min-width: 720px;
  }
}

@media (max-width: 640px) {
  .drawdown-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  .title-copy,
  .live-panel,
  .metric-card,
  .chart-section,
  .table-panel,
  .alert-panel,
  .source-panel {
    padding: 14px;
  }

  h1 {
    font-size: 32px;
  }

  .metric-value,
  .live-panel strong {
    font-size: 28px;
  }

  #drawdown-chart {
    height: 360px;
    min-height: 300px;
  }
}
