:root {
  --bg: #0d1210;
  --panel: #131b18;
  --panel-border: #223129;
  --text: #e6ece8;
  --text-dim: #8fa39a;
  --text-faint: #5c6f66;
  --accent-pos: #4fd18b;
  --accent-neg: #e2685b;
  --accent-line: #4fd18b;
  --rule: #1d2b24;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, #101713 0%, var(--bg) 100%);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--bg);
  background: var(--accent-pos);
  padding: 8px 10px;
  border-radius: 6px;
  line-height: 1;
}

.brand-text h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--text-dim);
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--mono);
}

.meta-label {
  font-size: 11px;
  color: var(--text-faint);
}

.meta-value {
  font-size: 14px;
  color: var(--text);
}

/* ---------- layout ---------- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 22px 24px;
}

.panel-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.panel-note {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 68ch;
}

/* ---------- summary stats ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-dim);
}

.stat-value.pos { color: var(--accent-pos); }
.stat-value.neg { color: var(--accent-neg); }

/* ---------- chart ---------- */

.chart-wrap {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #0f1613;
}

#trendChart {
  display: block;
  width: 100%;
  height: 260px;
}

/* ---------- tables ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 640px;
}

thead th {
  text-align: left;
  font-weight: 500;
  color: var(--text-faint);
  font-size: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 13px;
}

tbody td.name-cell {
  font-family: var(--sans);
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: rgba(255,255,255,0.02); }

td.edge-pos { color: var(--accent-pos); }
td.edge-neg { color: var(--accent-neg); }

.sizing-note {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.5;
}

/* ---------- checkbox column ---------- */

th.checkbox-col {
  width: 32px;
}

td.checkbox-cell {
  width: 32px;
}

td.checkbox-cell input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent-pos);
  cursor: pointer;
}

/* ---------- sizing panel ---------- */

.sizing-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sizing-label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.selected-legs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leg-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #0f1613;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13.5px;
}

.leg-chip-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leg-chip-name {
  font-family: var(--sans);
}

.leg-chip-detail {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}

.leg-chip-remove {
  background: none;
  border: 1px solid var(--rule);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--sans);
}

.leg-chip-remove:hover {
  color: var(--accent-neg);
  border-color: var(--accent-neg);
}

.sizing-input-row {
  max-width: 240px;
}

.sizing-input-row input {
  width: 100%;
  background: #0f1613;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 9px 12px;
}

.sizing-input-row input:focus {
  outline: none;
  border-color: var(--accent-pos);
}

.sizing-result {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 18px 20px;
  background: #0f1613;
}

.sizing-result.rejected {
  border-color: #4a2a26;
  background: #1c1210;
}

.sizing-stake-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.sizing-stake-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--accent-pos);
}

.sizing-stake-status {
  font-size: 12.5px;
  color: var(--text-dim);
}

.sizing-reject-text {
  font-size: 13.5px;
  color: #e2a29a;
  line-height: 1.5;
}

.sizing-breakdown {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 24px;
  font-size: 12.5px;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}

.sizing-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--mono);
  color: var(--text-dim);
}

.sizing-breakdown div span:last-child {
  color: var(--text);
}

@media (max-width: 640px) {
  .sizing-breakdown {
    grid-template-columns: 1fr;
  }
}

.empty-note {
  margin: 14px 2px 0;
  font-size: 13px;
  color: var(--text-faint);
}

.load-error {
  border: 1px solid #4a2a26;
  background: #1c1210;
  color: #e2a29a;
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 18px 24px 26px;
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .header-inner {
    align-items: flex-start;
  }
  .header-meta {
    align-items: flex-start;
  }
  .panel {
    padding: 18px;
  }
}
