:root {
  --gold: #d8a92f;
  --gold-dark: #a97708;
  --gold-soft: #fff4ce;
  --text: #151515;
  --muted: #777777;
  --line: #eeeeee;
  --buy: #14a86b;
  --sell: #e54d42;
  --danger: #c4372f;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #ffffff;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

.page {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.page-title {
  margin: 0;
  text-align: center;
  color: var(--gold-dark);
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.4px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
}

.icon-btn:active {
  background: var(--gold-soft);
  transform: scale(0.97);
}

.icon-btn .feather {
  width: 24px;
  height: 24px;
  stroke-width: 2.3;
}

.filter-menu {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 54px);
  right: 12px;
  z-index: 20;
  width: min(210px, calc(100vw - 24px));
  border: 1px solid #ead391;
  border-radius: 8px;
  padding: 6px;
  display: grid;
  gap: 2px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.14);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity 160ms ease, transform 160ms ease;
}

.filter-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.filter-option {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 0 9px 0 11px;
  display: grid;
  grid-template-columns: 1fr 18px;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.filter-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}

.filter-option .feather {
  width: 16px;
  height: 16px;
  color: var(--gold-dark);
  opacity: 0;
}

.filter-option.active {
  background: var(--gold-soft);
  color: var(--gold-dark);
}

.filter-option.active .feather {
  opacity: 1;
}

.filters {
  flex: 0 0 auto;
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.tag {
  min-height: 46px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 0 13px;
  display: inline-grid;
  place-items: center;
  white-space: nowrap;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.tag.active {
  border-bottom-color: var(--gold);
  background: linear-gradient(180deg, #ffffff 0%, #fffaf0 100%);
  color: var(--gold-dark);
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 18px;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.summary-item {
  min-width: 0;
  border: 1px solid #ead391;
  border-radius: 8px;
  padding: 11px;
  background: #fffdf7;
}

.summary-item span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.summary-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 950;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.history-top {
  width: 100%;
  border: 0;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #ffffff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.history-name {
  min-width: 0;
}

.history-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 950;
}

.history-time {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.history-amount {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 950;
}

.history-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.history-chevron {
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 160ms ease;
}

.history-card.expanded .history-chevron {
  transform: rotate(90deg);
}

.positive,
.buy-text {
  color: var(--buy);
}

.negative,
.sell-text {
  color: var(--sell);
}

.bonus-text,
.deposit-text {
  color: var(--gold-dark);
}

.withdraw-text {
  color: var(--danger);
}

.history-grid {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 12px 12px;
}

.history-card.expanded .history-grid {
  display: grid;
}

.meta {
  min-width: 0;
  border-radius: 8px;
  padding: 8px;
  background: #fafafa;
}

.meta span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.meta strong {
  display: block;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 900;
}

.empty {
  margin: 22px 0 0;
  padding: 22px 16px;
  border: 1px dashed #ead391;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  background: #fffdf7;
}

@media (max-width: 360px) {
  .topbar {
    height: 54px;
    flex-basis: 54px;
    grid-template-columns: 54px 1fr 54px;
  }

  .content {
    padding-inline: 12px;
  }
}
