:root {
  --bg: #0a0a0a;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.45);
  --text-dim: rgba(255, 255, 255, 0.28);
  --green: #34c759;
  --badge-done: rgba(52, 199, 89, 0.18);
  --badge-cancel: rgba(255, 255, 255, 0.08);
  --nav-h: 72px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(255, 255, 255, 0.04), transparent 60%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.02), transparent 40%);
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  padding: 20px 16px calc(var(--nav-h) + 24px);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.muted {
  color: var(--text-muted);
}

.center {
  text-align: center;
}

.greeting {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.balance-card {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: 18px 18px 16px;
  margin-bottom: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.04) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.balance-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.08), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.05), transparent 40%);
  pointer-events: none;
}

.balance-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.balance-label {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.balance-value {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.operators-status {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 199, 89, 0.6);
}

.status-dot.off {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.stat-tile {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px 10px 14px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.section-title {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.rate-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.rate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.rate-row + .rate-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.rate-name {
  color: var(--text-muted);
  font-size: 14px;
}

.rate-value {
  font-size: 16px;
  font-weight: 600;
}

.page-block {
  margin-bottom: 24px;
}

.deal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deal-item {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.deal-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.deal-title {
  font-size: 15px;
  font-weight: 600;
}

.deal-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.badge.done {
  background: var(--badge-done);
  color: var(--green);
}

.badge.cancel {
  background: var(--badge-cancel);
  color: var(--text-muted);
}

.badge.progress {
  background: rgba(255, 204, 0, 0.15);
  color: #ffcc00;
}

.empty-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.info-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
}

.info-row + .info-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.info-row span:first-child {
  color: var(--text-muted);
}

.info-row span:last-child {
  font-weight: 600;
}

.stub-card {
  background: var(--surface-2);
  border-radius: 18px;
  padding: 28px 20px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stub-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.stub-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  border: none;
  border-radius: 16px;
  padding: 16px 18px;
  min-height: 52px;
  background: #ffffff;
  color: #000000;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-block {
  margin-top: 12px;
}

.btn:disabled {
  opacity: 0.45;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.menu-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.menu-btn-accent {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.row-actions .menu-btn {
  flex: 1;
}

.icon-action {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-action:active {
  background: rgba(255, 255, 255, 0.14);
}

.turnover-card {
  border-radius: 18px;
  padding: 16px 14px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.turnover-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.turnover-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.turnover-rank {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-transform: lowercase;
}

.turnover-label {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.btn-success,
.btn-danger,
.btn-primary,
.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-sm {
  width: auto;
  padding: 10px 16px;
  min-height: 44px;
  margin: 0;
  font-size: 15px;
}

.input {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 16px 18px;
  min-height: 52px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.2);
}

.hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.hint.error {
  color: #ff6b6b;
}

.hint.success {
  color: var(--green);
}

.page-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.page-head-row .greeting {
  margin: 0;
}

.icon-refresh {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-refresh:active {
  transform: scale(0.96);
}

#toast-root {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-h) + 12px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  margin: 0 auto;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  background: rgba(30, 30, 30, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-color: rgba(52, 199, 89, 0.45);
  color: #9cffb8;
}

.toast-error {
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffb4b4;
}

.toast-info {
  color: rgba(255, 255, 255, 0.92);
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 0 0 14px;
  padding: 14px 18px;
  min-height: 52px;
  width: 100%;
  border: none;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.back-btn:active {
  opacity: 0.75;
  transform: scale(0.99);
}

main.page-sub {
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
}

main.page-chat {
  padding: 0;
  max-width: none;
  margin: 0;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

main.page-chat .chat-screen {
  flex: 1;
  min-height: 0;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.chip {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.chip.active {
  background: #fff;
  color: #000;
  border-color: #fff;
}

.step-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.step {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.step.active {
  color: var(--text);
}

.bank-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  margin-top: 10px;
}

.bank-chip {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
}

.bank-chip.active {
  border-color: #fff;
}

.req-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.req-item {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
}

.req-item strong {
  display: block;
  margin-bottom: 4px;
}

.req-item span {
  font-size: 13px;
  color: var(--text-muted);
}

.req-item.active {
  border-color: #fff;
}

.deal-item.clickable {
  cursor: pointer;
}

.deal-item.clickable:active {
  opacity: 0.85;
}

.payment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  margin-bottom: 8px;
}

.pay-actions {
  display: flex;
  gap: 8px;
}

.success-card {
  background: rgba(52, 199, 89, 0.12);
  border: 1px solid rgba(52, 199, 89, 0.25);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
}

.success-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.success-card p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 0;
}

.nav-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.2s;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

.nav-item.active {
  color: var(--text);
}

.nav-item.active .nav-dot {
  background: var(--text);
}

.chat-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.chat-top {
  flex-shrink: 0;
  padding: 10px 12px 8px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg);
}

.chat-top .back-btn {
  width: 100%;
  margin: 0;
}

.chat-box {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  max-width: 90%;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  align-self: flex-start;
}

.chat-msg.mine {
  align-self: flex-end;
  background: rgba(52, 199, 89, 0.28);
}

.chat-msg-pending {
  opacity: 0.72;
}

.chat-text {
  font-size: 17px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-photo {
  display: block;
  max-width: min(100%, 320px);
  border-radius: 14px;
  margin-bottom: 4px;
}

.chat-compose {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  background: rgba(8, 8, 8, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-input {
  flex: 1;
  min-width: 0;
  height: 52px;
  margin: 0;
  padding: 0 18px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 17px;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.chat-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-icon-btn {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.chat-icon-btn:active {
  opacity: 0.72;
  transform: scale(0.96);
}

.chat-send-btn {
  background: #ffffff;
  color: #000000;
  width: 48px;
  height: 48px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.chat-send-btn:active {
  opacity: 1;
  transform: scale(0.94);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.22);
}

.chat-send-icon {
  width: 21px;
  height: 21px;
  display: block;
  margin-left: 2px;
}

.chat-status {
  flex-shrink: 0;
  margin: 0;
  padding: 0 12px 4px;
  min-height: 0;
  font-size: 13px;
}

.chat-box .empty-box {
  margin: auto;
  width: 100%;
  padding: 24px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.tx-row {
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tx-main {
  font-weight: 600;
  margin-bottom: 4px;
}

.tx-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.bank-empty {
  margin-top: 14px;
  padding: 18px 16px;
  text-align: center;
  border-radius: 16px;
  background: var(--surface);
  border: 1px dashed rgba(255, 255, 255, 0.1);
}

.bank-support-wrap {
  margin-top: 16px;
  text-align: center;
}

.support-link {
  display: inline-block;
  border: none;
  background: none;
  padding: 8px 4px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.support-link:active {
  opacity: 0.7;
}

.bank-empty-text {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.save-req-block {
  margin-top: 8px;
}

@media (prefers-reduced-motion: no-preference) {
  #content.page-enter {
    animation: pageEnter 0.48s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  @keyframes pageEnter {
    from {
      opacity: 0;
      transform: translateY(14px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .balance-card,
  .turnover-card,
  .info-card,
  .stat-tile,
  .deal-item,
  .rate-card,
  .success-card,
  .stub-card,
  .empty-box {
    animation: cardEnter 0.52s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .stat-tile:nth-child(2) {
    animation-delay: 40ms;
  }

  .stat-tile:nth-child(3) {
    animation-delay: 80ms;
  }

  @keyframes cardEnter {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .bank-chip {
    animation: chipEnter 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  @keyframes chipEnter {
    from {
      opacity: 0;
      transform: scale(0.96);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }

  .bank-empty {
    animation: cardEnter 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .btn,
  .chip,
  .bank-chip,
  .req-item,
  .back-btn,
  .nav-item,
  .deal-item.clickable {
    transition:
      transform 0.16s ease,
      opacity 0.16s ease,
      background 0.2s ease,
      border-color 0.2s ease,
      color 0.2s ease;
  }

  .btn:active:not(:disabled),
  .chip:active,
  .bank-chip:active,
  .req-item:active,
  .back-btn:active,
  .deal-item.clickable:active {
    transform: scale(0.985);
  }

  .step {
    transition: color 0.25s ease, opacity 0.25s ease;
  }

  .nav-dot {
    transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  }

  .nav-item.active .nav-dot {
    transform: scale(1.35);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
  }

  .status-dot:not(.off) {
    animation: pulseDot 2.4s ease-in-out infinite;
  }

  @keyframes pulseDot {
    0%,
    100% {
      box-shadow: 0 0 8px rgba(52, 199, 89, 0.5);
    }
    50% {
      box-shadow: 0 0 14px rgba(52, 199, 89, 0.85);
    }
  }
}
