:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #999999);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f2f2f2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}

.topbar .logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.topbar h1 {
  font-size: 17px;
  margin: 0;
}

main {
  padding: 0 16px;
}

.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--hint);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 14px;
}

.search-form button,
.fav-add-btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: var(--button);
  color: var(--button-text);
  font-size: 14px;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.tab-btn {
  flex: none;
  padding: 8px 14px;
  border-radius: 20px;
  border: none;
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 13px;
}

.tab-btn.active {
  background: var(--button);
  color: var(--button-text);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.status {
  min-height: 18px;
  color: var(--hint);
  font-size: 13px;
  margin-bottom: 8px;
}

.card {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.card .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
}

.card .label {
  color: var(--hint);
}

.addr {
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
}

.tx-item {
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
  padding: 10px 0;
  font-size: 14px;
}

.tx-item:last-child {
  border-bottom: none;
}

.tx-amount.in {
  color: #2ecc71;
}

.tx-amount.out {
  color: #e74c3c;
}

.tx-time {
  color: var(--hint);
  font-size: 12px;
}

.fav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.fav-remove {
  color: #e74c3c;
  background: none;
  border: none;
  font-size: 13px;
}

.empty {
  color: var(--hint);
  text-align: center;
  padding: 24px 0;
  font-size: 14px;
}

.hidden {
  display: none;
}

.gate {
  text-align: center;
  padding: 32px 16px;
}

.gate p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.gate .balance-line {
  color: var(--hint);
  font-size: 13px;
  margin-top: 8px;
}

#ton-connect-button {
  display: flex;
  justify-content: center;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-row .label {
  flex: 1;
}

.token-amounts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.token-img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(128, 128, 128, 0.15);
}

.token-img.placeholder {
  background: rgba(128, 128, 128, 0.15);
}

.pnl-note {
  color: var(--hint);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 12px;
}
