:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2230;
  --line: #2a3140;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --up: #3fb950;
  --down: #f85149;
  --hold: #d29922;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header {
  padding: 44px 24px 28px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: -1.4px;
  font-weight: 700;
}
h1 .accent { color: var(--accent); }
.tagline { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.tagline em { color: var(--text); font-style: normal; font-weight: 600; }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

h2 { font-size: 17px; margin: 0; font-weight: 600; }

/* ---- controls ---- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
}
.field { display: flex; flex-direction: column; gap: 7px; }
/* Forces the wrap so the two fee boxes always start a fresh line together, rather
   than one trailing the period buttons and the other stranded below. */
.row-break { flex-basis: 100%; height: 0; margin: 0; }
.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-weight: 600;
}
select, input[type=number], #ticker {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 15px;
  font-family: inherit;
}
select { min-width: 210px; }
#ticker { min-width: 260px; }
#ticker::-webkit-calendar-picker-indicator { opacity: .45; }
select:focus, input:focus, #ticker:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.money-input {
  display: flex;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding-left: 11px;
}
.money-input span { color: var(--muted); }
.money-input input { border: none; background: none; width: 108px; padding-left: 4px; }
.money-input input:focus { outline: none; }
.money-input:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }

.range-group, .strategy-group { display: flex; gap: 6px; flex-wrap: wrap; }
.range-group button, .strategy-group button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 7px;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.range-group button:hover, .strategy-group button:hover { color: var(--text); border-color: #3d4757; }
.range-group button.on, .strategy-group button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 600;
}

.period-note { color: var(--muted); font-size: 13px; margin: 14px 2px 0; }

/* ---- result cards ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--c);
  border-radius: 10px;
  padding: 18px 20px;
}
.card .title { font-size: 13px; color: var(--c); font-weight: 700; letter-spacing: .2px; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card .balance {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-top: 14px;
  font-variant-numeric: tabular-nums;
}
.card .pct { font-size: 17px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}
.up { color: var(--up); }
.down { color: var(--down); }

/* ---- chart ---- */
.chart-section, .table-section, .explainer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-top: 20px;
}
.chart-head, .table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.log-toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.hint { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; }
#chart { min-height: 340px; }

.u-legend { font-size: 13px; }
.u-legend .u-marker { width: 10px; height: 10px; }

/* ---- leaderboards ---- */
.boards-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-top: 20px;
}
.boards-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.boards-mode { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.boards-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.boards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 14px;
}
.board {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-top: 3px solid var(--c);
  border-radius: 9px;
  padding: 14px 15px 6px;
}
.board > h3 {
  margin: 0 0 2px;
  font-size: 13px;
  color: var(--c);
  font-weight: 700;
}
.board .board-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.board h4 {
  margin: 12px 0 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  font-weight: 700;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.board h4:first-of-type { border-top: none; padding-top: 0; }
.board ol { list-style: none; margin: 0; padding: 0; }
.board li {
  display: grid;
  grid-template-columns: 1.7em 3.6em minmax(0, 1fr) auto;
  grid-template-areas: "rank sym nm primary" "rank sym nm secondary";
  align-items: center;
  gap: 0 8px;
  padding: 5px 4px;
  margin: 0 -4px;
  border-radius: 5px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.board li:hover { background: #232b3a; }
.board li .rank { grid-area: rank; color: #5c6470; font-size: 11.5px; }
.board li .sym { grid-area: sym; font-weight: 600; font-size: 12.5px; }
.board li .nm {
  grid-area: nm;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board li .primary { grid-area: primary; font-weight: 600; text-align: right; }
.board li .secondary {
  grid-area: secondary;
  color: var(--muted);
  font-size: 11.5px;
  text-align: right;
}

/* ---- fees ---- */
.fee-note {
  color: var(--hold);
  font-size: 12.5px;
  margin: 8px 2px 0;
  border-left: 3px solid var(--hold);
  padding-left: 11px;
}
.fee-note[hidden] { display: none; }
td.fee { color: var(--hold); }
tr.dead td { opacity: .45; }

/* ---- daily table ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td {
  padding: 9px 13px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  position: sticky;
  top: 0;
}
td { font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--panel-2); }
.num { text-align: right; }
td.num { text-align: right; }
.balance-col { font-weight: 600; }

.table-foot {
  margin-top: 13px;
  display: flex;
  align-items: center;
  gap: 14px;
}
#more {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 15px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
#more:hover { border-color: var(--accent); color: var(--accent); }
#more[hidden] { display: none; }
#rowcount { color: var(--muted); font-size: 12.5px; }

/* ---- explainer ---- */
.explainer p, .explainer li { color: #c3ccd6; font-size: 14.5px; }
.explainer ul { padding-left: 20px; }
.explainer strong { color: var(--text); }
.disclaimer {
  border-left: 3px solid var(--hold);
  padding-left: 14px;
  color: var(--muted) !important;
  font-size: 13px !important;
}

footer {
  border-top: 1px solid var(--line);
  padding: 22px 24px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

@media (max-width: 600px) {
  h1 { font-size: 30px; }
  main { padding: 20px 14px 40px; }
  .card .balance { font-size: 25px; }
  select, #ticker { min-width: 0; width: 100%; }
  .field { width: 100%; }
  .boards-section, .chart-section, .table-section, .explainer { padding: 14px 13px; }
  .board li { font-size: 12.5px; gap: 6px; }
}
