:root {
  --blue: #0A84FF;
  --blue-dark: #0056CC;
  --blue-glow: rgba(10, 132, 255, 0.35);
  --bg: #0a0a0c;
  --card: rgba(28, 28, 32, 0.92);
  --card-border: rgba(255, 255, 255, 0.06);
  --text: #ffffff;
  --muted: #9a9aa3;
  --danger: #ff453a;
  --warn: #ffd60a;
  --ok: #30d158;
  --radius: 18px;
  --nav-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(10, 132, 255, 0.12), transparent),
    url('/static/assets/bg.svg');
  background-repeat: no-repeat, repeat;
  background-size: 100% 40%, 280px;
  background-position: top center, center 60%;
}

#app {
  min-height: 100vh;
  padding: 12px 14px calc(var(--nav-h) + 16px);
  max-width: 480px;
  margin: 0 auto;
}

.screen { display: none; animation: fadeIn 0.2s ease; }
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(12px);
}

.card-glow {
  background: linear-gradient(145deg, rgba(10, 132, 255, 0.22) 0%, rgba(28, 28, 32, 0.95) 55%);
  border-color: rgba(10, 132, 255, 0.25);
  box-shadow: 0 8px 32px rgba(10, 132, 255, 0.12);
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.pill.blue { background: rgba(10, 132, 255, 0.2); color: #7ec8ff; }
.pill.ok { background: rgba(48, 209, 88, 0.15); color: var(--ok); }
.pill.warn { background: rgba(255, 214, 10, 0.15); color: var(--warn); }
.pill.bad { background: rgba(255, 69, 58, 0.15); color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { opacity: 0.85; transform: scale(0.98); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,0.2); }
.btn-ghost { background: rgba(255,255,255,0.06); color: var(--text); }
.btn-white { background: #fff; color: #111; }
.btn-sm { padding: 10px 12px; font-size: 13px; width: auto; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.key-id {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.muted { color: var(--muted); font-size: 13px; line-height: 1.45; }

.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 12px 0;
}

.link-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  outline: none;
  min-width: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn-ghost {
  background: transparent;
}

.svg-icon {
  display: block;
  flex-shrink: 0;
}

.icon-muted {
  color: var(--muted);
  opacity: 0.7;
}

.icon-empty {
  margin: 0 auto 12px;
  color: var(--muted);
  opacity: 0.45;
}

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

.tab {
  flex: 1;
  min-width: max-content;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: rgba(255,255,255,0.14);
  color: var(--text);
}

.subtabs { margin-bottom: 12px; }

.platform-tabs {
  display: flex;
  gap: 6px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.platform-tab {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.platform-tab.active { background: rgba(10,132,255,0.25); color: #fff; }

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

.chip {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  border-color: var(--blue);
  background: rgba(10,132,255,0.2);
}

.amount-display {
  font-size: 36px;
  font-weight: 800;
  margin: 8px 0 4px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  background: rgba(12, 12, 14, 0.95);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  backdrop-filter: blur(16px);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 8px 12px;
  min-width: 64px;
}

.nav-item .ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: inherit;
}

.nav-item.active { color: var(--text); }
.nav-item.active .ico { color: var(--blue); }

.toast {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  max-width: 456px;
  margin: 0 auto;
  background: var(--blue);
  color: #fff;
  padding: 14px 16px;
  border-radius: 14px;
  font-weight: 600;
  z-index: 200;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 24px var(--blue-glow);
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.toast.hide { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  border: 1px solid var(--card-border);
}

.search {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border-radius: 14px;
  border: none;
  background: rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
}

.search-wrap { position: relative; }
.search-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  opacity: 0.55;
  pointer-events: none;
}

.tx-item {
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tx-item:last-child { border-bottom: none; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--blue);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  padding: 0;
}

.back-ico {
  display: inline-flex;
  align-items: center;
  margin-right: 2px;
}

.pill.bad .status-dot { background: var(--danger); }
.pill.ok .status-dot { background: var(--ok); }
.pill.warn .status-dot { background: var(--warn); }

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  background: currentColor;
}

.faq-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  opacity: 0.6;
}

.modal.modal-chat {
  max-height: 92vh;
  height: min(85vh, 640px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.modal-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.support-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  min-height: 0;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.admin {
  align-self: flex-start;
  background: rgba(255,255,255,0.08);
  border-bottom-left-radius: 4px;
}

.chat-time {
  font-size: 11px;
  opacity: 0.55;
  margin-top: 4px;
}

.support-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.support-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 14px;
  border: none;
  background: rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 15px;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  font-family: inherit;
}

.support-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.support-send:disabled {
  opacity: 0.45;
  cursor: default;
}

.support-empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: auto;
  padding: 24px 16px;
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 14px;
}

.slider-wrap { margin: 16px 0; }
.slider-wrap input[type=range] { width: 100%; accent-color: var(--blue); }

/* ── Plan change tab ── */
.plan-change-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.plan-key {
  color: var(--text);
}

.plan-change-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.plan-slider-card {
  padding: 16px;
  margin-bottom: 12px;
}

.plan-slider-head {
  margin-bottom: 14px;
}

.plan-dev-count {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.plan-slider {
  width: 100%;
  height: 4px;
  accent-color: #fff;
  cursor: pointer;
}

.card-compare {
  background: linear-gradient(145deg, rgba(10, 132, 255, 0.28) 0%, rgba(20, 24, 32, 0.96) 55%);
  border-color: rgba(10, 132, 255, 0.22);
  padding: 16px;
  margin-bottom: 12px;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  gap: 8px;
  align-items: center;
}

.compare-col-end {
  text-align: right;
}

.compare-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.35;
}

.compare-val {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.compare-val-ok { color: var(--ok); }
.compare-val-warn { color: #ff9f6b; }
.compare-val-price { color: var(--text); font-size: 18px; }

.compare-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: 0.55;
  padding-top: 18px;
}

.btn-plan-confirm {
  margin-top: 4px;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.55) 0%, rgba(10, 132, 255, 0.22) 100%);
  border: 1px solid rgba(10, 132, 255, 0.35);
  color: #e8f4ff;
  font-weight: 700;
}

.btn-plan-confirm:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 69, 58, 0.4);
}

.btn-danger:active {
  background: rgba(255, 69, 58, 0.12);
}

/* ── Devices tab ── */
.devices-tab-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.device-client-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  background: rgba(28, 28, 32, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
}

.device-platform-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(10, 132, 255, 0.18);
  color: #7ec8ff;
}

.device-platform-icon.ios {
  background: rgba(48, 209, 88, 0.15);
  color: #5ee87a;
}

.device-client-info {
  flex: 1;
  min-width: 0;
}

.device-client-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.device-client-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 2px;
}

.device-remove-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 69, 58, 0.2);
  color: #ff6b63;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.device-remove-btn:active {
  opacity: 0.8;
}

.checkout-plan {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(28, 28, 32, 0.95);
}

.checkout-plan-active {
  border-color: rgba(10, 132, 255, 0.45);
  background: linear-gradient(145deg, rgba(10, 132, 255, 0.18) 0%, rgba(28, 28, 32, 0.95) 55%);
}

.loading { text-align: center; padding: 40px; color: var(--muted); }

.brand-mark {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(10, 132, 255, 0.8);
  margin-bottom: 2px;
}
