:root {
  --color-bg: #141A33;
  --color-surface-1: #1D2445;
  --color-surface-2: #232B52;
  --color-border: #2C3561;
  --color-text-1: #F1F0F7;
  --color-text-2: #B4B8D4;
  --color-text-3: #9AA0C2;
  --color-accent: #FF7A1A;
  --color-accent-hover: #FF8F3D;
  --color-profit: #7CE0C3;
  --color-warning: #FFC94D;
  --color-loss: #FF5470;
  --color-on-accent: #141A33;
  --font-display: "Unbounded", sans-serif;
  --font-text: "Onest", sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --space: 4px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-text-1);
  font-family: var(--font-text);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
}

body {
  padding-top: var(--tg-content-safe-area-inset-top, 0px);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 16px 16px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.topbar-side {
  position: relative;
  flex: 0 0 auto;
}

.menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 8px;
  border: 0;
  background: none;
}

.menu-btn span {
  display: block;
  width: 16px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--color-text-2);
}

.menu-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 132px;
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}

.menu-pop button {
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--color-text-1);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.menu-pop button:hover {
  background: var(--color-surface-1);
}

.wordmark {
  margin-right: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text-1);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.pro-btn {
  flex: 0 0 auto;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.pro-btn:hover,
.pro-btn:focus-visible {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.topbar-meta,
.caption {
  margin: 0;
  color: var(--color-text-3);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen[hidden],
[hidden] {
  display: none !important;
}

.display {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 8vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.15;
}

.h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.25;
}

.h3 {
  margin: 0;
  font-family: var(--font-text);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.35;
}

.body {
  margin: 0;
  color: var(--color-text-2);
}

.sum {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.card {
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-1);
}

.card + .card,
#rank-list .card {
  margin-top: 12px;
}

.block {
  margin-top: 48px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
  overflow: visible;
}

.chip {
  position: relative;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  color: var(--color-text-2);
  font-size: 13px;
  font-weight: 500;
}

.chip.is-on {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-on-accent);
}

#activity-list {
  margin-top: 12px;
}

#activity-list .card {
  margin-bottom: 12px;
}

.scale {
  display: grid;
  grid-template-columns: repeat(var(--slots, 48), minmax(0, 1fr));
  align-items: end;
  gap: 2px;
  height: 112px;
  margin-top: 16px;
  overflow: visible;
}

.scale .bar {
  position: relative;
  display: flex;
  align-items: flex-end;
  height: 100%;
  min-width: 0;
}

.scale .bar::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 3;
  width: max-content;
  max-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-1);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(4px);
}

.scale .bar:hover::after,
.scale .bar.is-tip::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.scale i {
  display: block;
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--color-border);
}

.scale i.is-now {
  background: var(--color-profit);
}

.scale i.is-hot {
  background: var(--color-accent);
}

.scale-axis {
  display: flex;
  justify-content: space-between;
  margin: 6px 0 4px;
  color: var(--color-text-3);
  font-size: 12px;
  font-weight: 500;
}

.scale-tip {
  min-height: 1.4em;
  margin: 0 0 12px;
}

.chip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 2;
  width: max-content;
  max-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-1);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(4px);
}

.chip:hover::after,
.chip:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--color-text-3);
  font-size: 13px;
  font-weight: 500;
}

.field {
  width: 100%;
  height: 48px;
  margin-bottom: 16px;
  padding: 0 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-1);
  font-variant-numeric: tabular-nums;
}

.field::placeholder {
  color: var(--color-text-3);
}

.field:focus {
  outline: none;
  border-color: var(--color-accent);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--color-accent-hover);
}

.btn-ghost {
  background: var(--color-surface-1);
  color: var(--color-text-1);
  border: 1px solid var(--color-border);
}

.btn-inline {
  width: 100%;
  margin-top: 16px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.badge-profit {
  background: var(--color-profit);
  color: var(--color-on-accent);
}

.badge-warn {
  background: var(--color-warning);
  color: var(--color-on-accent);
}

.badge-loss {
  background: var(--color-loss);
  color: var(--color-on-accent);
}

.route-head,
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.route-pair {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.25;
}

.route-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.route-arrow {
  color: var(--color-accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
  padding-bottom: 4px;
}

.route-meta {
  margin-top: 16px;
  color: var(--color-text-3);
  font-size: 13px;
  font-weight: 500;
}

.route-label {
  margin: 0 0 8px;
}

.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-3);
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  vertical-align: 1px;
}

.help:hover,
.help.is-on {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.help-pop {
  position: fixed;
  z-index: 30;
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-1);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.advice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 12px 0;
}

.amount-suggest {
  margin: 12px 0 0;
  color: var(--color-profit);
}

.playbook {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--color-text-1);
  font-size: 14px;
  font-weight: 500;
}

.playbook li + li {
  margin-top: 6px;
}

.route-kind {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  color: var(--color-text-2);
  font-size: 13px;
  font-weight: 500;
}

.pay-qr {
  box-sizing: content-box;
  width: 222px;
  height: 222px;
  margin: 0 auto 16px;
  padding: 12px;
  border-radius: 16px;
  background: #fff;
  line-height: 0;
}

.pay-qr:empty {
  display: none;
}

.pay-qr svg,
.pay-qr img {
  display: block;
  width: 222px;
  height: 222px;
  shape-rendering: crispEdges;
  image-rendering: pixelated;
}

.topbar .btn-inline {
  margin-left: 8px;
}

.wallet {
  margin: 8px 0 0;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-1);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

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

.table th {
  color: var(--color-text-3);
  font-size: 13px;
  font-weight: 500;
}

.table td {
  border-top: 1px solid var(--color-border);
  color: var(--color-text-1);
}

.error {
  margin-top: 16px;
  color: var(--color-loss);
}

.hour-card .caption {
  margin-bottom: 8px;
}
