:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-muted: #f1f5f9;
  --line: #d6dee8;
  --line-strong: #b8c4d2;
  --text: #111827;
  --muted: #475569;
  --subtle: #6b7280;
  --accent: #146c58;
  --accent-hover: #0f5a49;
  --accent-2: #244f8f;
  --danger: #b91c1c;
  --success: #147253;
  --focus: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.2;
}

p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.actions,
.add-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input,
select {
  padding: 0 10px;
}

input::placeholder {
  color: #5f6f84;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
.line-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button {
  padding: 0 14px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.layout {
  display: grid;
  grid-template-columns: 296px 1fr;
  min-height: calc(100vh - 73px);
}

.sidebar {
  padding: 16px;
  border-right: 1px solid var(--line);
  background: var(--panel-muted);
}

.add-form {
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chain-note {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.market {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 750;
}

.content {
  min-width: 0;
  padding: 16px 18px 28px;
}

.status {
  min-height: 20px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 440px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  max-width: 300px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.14);
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
}

.tooltip-title {
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 750;
}

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

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-wrap {
  max-height: 520px;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f8;
  color: #334155;
  font-weight: 720;
}

tbody tr:hover td {
  background: #f8fafc;
}

.section-row td {
  position: sticky;
  top: 36px;
  z-index: 1;
  padding: 8px 10px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  background: #e8eef6;
  color: #1e3a5f;
  font-weight: 760;
  text-align: left;
}

th:nth-child(1),
th:nth-child(2),
th:nth-child(3),
th:nth-child(4),
th:nth-child(5),
th:nth-child(6),
td:nth-child(1),
td:nth-child(2),
td:nth-child(3),
td:nth-child(4),
td:nth-child(5),
td:nth-child(6) {
  text-align: left;
}

.line-toggle {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

.positive {
  color: var(--danger);
  font-weight: 750;
}

.negative {
  color: var(--success);
  font-weight: 750;
}

@media (max-width: 860px) {
  body {
    font-size: 13px;
  }

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

  .topbar {
    gap: 14px;
    padding: 14px 16px;
  }

  h1 {
    font-size: 24px;
  }

  p {
    max-width: 34rem;
    font-size: 13px;
    line-height: 1.45;
  }

  label {
    gap: 6px;
    font-size: 13px;
  }

  input,
  select,
  button {
    height: 34px;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .sidebar {
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .add-form {
    padding: 10px;
  }

  .content {
    padding: 12px 14px 22px;
  }

  .chart-wrap {
    height: 320px;
  }

  .table-wrap {
    max-height: 460px;
  }
}

@media (max-width: 520px) {
  .topbar {
    position: static;
  }

  h1 {
    font-size: 22px;
  }

  .chart-wrap {
    height: 300px;
  }

  th,
  td {
    padding: 8px 9px;
  }
}
