:root {
  --bg: #0e1116;
  --bg-soft: #151a22;
  --card: #1a2029;
  --card-2: #202836;
  --text: #e9eef6;
  --hint: #8b96a7;
  --accent: #2ea6ff;
  --accent-text: #ffffff;
  --border: rgba(255, 255, 255, 0.07);
  --ok: #3ddc84;
  --warn: #ffb020;
  --err: #ff5c5c;
  --radius: 16px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  min-height: 100%;
}

body { overscroll-behavior-y: none; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 14px calc(84px + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------- topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 2px 10px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(14, 17, 22, 0));
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: .5px;
  color: #06121d;
  background: linear-gradient(135deg, #56c8ff, #2ea6ff);
  box-shadow: 0 6px 18px rgba(46, 166, 255, .28);
}

.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--hint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.96); }

/* -------------------------------------------------------------- chips --- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 10px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.chip-sub { padding-top: 0; }
.chip-sub .chip { padding: 7px 12px; font-size: 12.5px; font-weight: 500; }

/* --------------------------------------------------------------- grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.card {
  position: relative;
  text-align: left;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card-2), var(--card));
  color: var(--text);
  border-radius: var(--radius);
  padding: 13px 13px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 112px;
}
.card:active { transform: scale(.985); }
.card[disabled] { opacity: .45; cursor: not-allowed; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-nominal { font-size: 17px; font-weight: 750; line-height: 1.15; }
.card-region { color: var(--hint); font-size: 11.5px; margin-top: 2px; }

.badge {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  color: #0c1720;
  background: linear-gradient(135deg, #8ff0c0, #3ddc84);
  border-radius: 999px;
  padding: 3px 7px;
  white-space: nowrap;
}

.card-price { margin-top: auto; display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.price-rub { font-size: 16px; font-weight: 750; }
.price-usdt { font-size: 11.5px; color: var(--hint); }
.card-stock { font-size: 10.5px; color: var(--hint); }

/* ------------------------------------------------------------- orders --- */
.orders { display: flex; flex-direction: column; gap: 10px; }

.order {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.order-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.order-title { font-weight: 650; font-size: 14px; line-height: 1.3; }
.order-sub { color: var(--hint); font-size: 11.5px; margin-top: 3px; }
.order-sum { font-weight: 700; font-size: 14px; white-space: nowrap; }

.status {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 650;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  color: var(--hint);
}
.status-pending { color: var(--warn); border-color: rgba(255, 176, 32, .35); }
.status-completed { color: var(--ok); border-color: rgba(61, 220, 132, .35); }
.status-cancelled, .status-error { color: var(--err); border-color: rgba(255, 92, 92, .35); }
.status-paid, .status-requires_operator { color: var(--accent); border-color: rgba(46, 166, 255, .35); }

.code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 9px 10px;
}
.code {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
.copy {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.copy:active { transform: scale(.97); }

/* -------------------------------------------------------------- state --- */
.state {
  color: var(--hint);
  text-align: center;
  padding: 34px 12px;
  font-size: 13.5px;
  line-height: 1.5;
}

/* ------------------------------------------------------------- tabbar --- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: rgba(14, 17, 22, .92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  max-width: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--hint);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab.is-active { color: var(--text); background: var(--card); }
.tab-ico { font-size: 15px; }

/* -------------------------------------------------------------- sheet --- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-soft);
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .5);
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .18);
  margin: 2px auto 12px;
}
.sheet-title { margin: 0 0 4px; font-size: 18px; line-height: 1.25; }
.sheet-meta { color: var(--hint); font-size: 12.5px; margin-bottom: 14px; }

.pay-list { display: flex; flex-direction: column; gap: 9px; }
.pay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--card);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.pay:active { transform: scale(.99); }
.pay-left { display: flex; flex-direction: column; gap: 2px; }
.pay-name { font-weight: 650; font-size: 14px; }
.pay-note { color: var(--hint); font-size: 11.5px; }
.pay-sum { font-weight: 750; font-size: 15px; white-space: nowrap; }
.pay-sbp { border-color: rgba(46, 166, 255, .35); }
.pay-usdt { border-color: rgba(61, 220, 132, .3); }

.ghost {
  width: 100%;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--hint);
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* -------------------------------------------------------------- toast --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 560px);
  background: #232c3a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  text-align: center;
}

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
