:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --ink: #20231f;
  --muted: #687064;
  --line: #dfe4da;
  --green: #16794c;
  --red: #b83b43;
  --accent: #3563a9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

.page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow,
p {
  margin: 0;
}

.eyebrow,
.section-note,
small {
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 18px;
}

.hidden {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 22px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.auth-panel {
  max-width: 420px;
}

.auth-form {
  display: flex;
  gap: 8px;
  margin: 14px 0 8px;
}

.auth-form input {
  flex: 1;
}

.auth-form input,
.auth-form button,
.icon-button,
.chart-actions button {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.auth-form input {
  height: 40px;
  padding: 0 10px;
}

.auth-form button,
.icon-button {
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  height: 40px;
  padding: 0 14px;
}

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

.chart-actions {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.chart-actions button {
  min-width: 76px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 8px 10px;
}

.chart-actions button + button {
  border-left: 1px solid var(--line);
}

.chart-actions button.active {
  background: var(--accent);
  color: #fff;
}

.chart-wrap {
  min-height: 260px;
}

.price-chart {
  display: block;
  width: 100%;
  height: 260px;
}

.chart-y-label {
  fill: var(--muted);
  font-size: 12px;
  text-anchor: end;
}

.chart-y-label-middle {
  fill: var(--ink);
  font-weight: 700;
}

.chart-axis {
  stroke: var(--line);
  stroke-width: 2;
}

.chart-grid {
  stroke: #edf0e8;
  stroke-width: 1;
}

.chart-tick {
  stroke: var(--line);
  stroke-width: 1.5;
}

.chart-tick-label {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
}

.chart-baseline {
  stroke: #9aa3a0;
  stroke-dasharray: 5 5;
  stroke-width: 1.5;
}

.chart-line,
.bot-asset-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line {
  stroke: var(--accent);
  stroke-width: 3;
}

.bot-asset-line {
  stroke-width: 2.5;
}

.chart-hit {
  cursor: crosshair;
  fill: transparent;
  pointer-events: all;
}

.chart-guide {
  stroke: #7fa4d6;
  stroke-width: 1;
  pointer-events: none;
}

.chart-tooltip {
  pointer-events: none;
}

.chart-tooltip rect {
  fill: #ffffff;
  stroke: var(--line);
}

.chart-tooltip text {
  fill: var(--ink);
  font-size: 13px;
}

.chart-tooltip-time {
  fill: var(--muted);
  font-size: 12px;
}

.chart-tooltip-price.positive,
.chart-tooltip-detail.positive {
  fill: var(--green);
}

.chart-tooltip-price.negative,
.chart-tooltip-detail.negative {
  fill: var(--red);
}

.bot-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 8px;
}

.bot-chart-legend button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
}

.bot-chart-legend button.active {
  border-color: var(--accent);
  color: var(--ink);
  background: #f3f7ff;
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 999px;
}

.legend-all {
  background: linear-gradient(90deg, #3563a9, #16794c, #b45f06);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.bot-table {
  border-collapse: separate;
  border-spacing: 0 8px;
}

.bot-table thead tr:first-child th {
  border-bottom: 1px solid var(--line);
  padding-top: 0;
}

.bot-table thead tr:nth-child(2) th {
  font-size: 12px;
  padding-top: 8px;
}

.bot-table tbody td {
  background: #fff;
  border-bottom: 1px solid #e8ede4;
  border-top: 1px solid #e8ede4;
  padding: 14px 12px;
}

.bot-table tbody td:first-child {
  border-left: 1px solid #e8ede4;
  border-radius: 8px 0 0 8px;
}

.bot-table tbody td:last-child {
  border-radius: 0 8px 8px 0;
  border-right: 1px solid #e8ede4;
}

.primary-cell,
.primary-header {
  background: #f8faf4;
}

.primary-group-header {
  color: var(--ink);
}

.detail-group-header {
  text-align: center;
}

.bot-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.bot-dot {
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.asset-main {
  display: block;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

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

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

.negative {
  color: var(--red);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.trade-list,
.summary-list {
  display: grid;
  gap: 10px;
}

.trade-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.trade-row p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.buy {
  background: #e3f3e9;
  color: var(--green);
}

.badge.sell {
  background: #f9e4e6;
  color: var(--red);
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.summary-list span {
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

@media (max-width: 780px) {
  .page {
    width: min(100% - 20px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

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

  .metric strong {
    font-size: 18px;
  }

  .chart-actions {
    width: 100%;
  }

  .chart-actions button {
    flex: 1;
    min-width: 0;
  }

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

  .auth-form {
    flex-direction: column;
  }
}
