:root {
  --bg: #0c0405;
  --bg-elevated: #170809;
  --card-bg: #1c090b;
  --card-bg-soft: #260c0f;
  --border: #3d151a;
  --accent: #ff3b3b;
  --accent-dim: rgba(255, 59, 59, 0.16);
  --text: #f6efef;
  --text-dim: #b08a8c;
  --text-faint: #7a5658;
  --danger: #ff9f43;
  --success: #5fe3a1;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: radial-gradient(ellipse 900px 500px at 15% -10%, rgba(255, 59, 59, 0.18), transparent 60%), var(--bg);
  background-attachment: fixed;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1), padding 0.28s ease, border-color 0.28s ease;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right-color: transparent;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 22px;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.brand-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--accent-dim), 0 4px 16px -4px rgba(255, 59, 59, 0.55);
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.brand-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 8px;
  border-radius: 999px;
}

.sidebar-header.no-avatar .brand {
  visibility: hidden;
}

.menu-toggle-inline {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--card-bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.menu-toggle-inline:hover {
  border-color: var(--accent);
}

.menu-toggle-inline:active {
  transform: scale(0.92);
}

.menu-toggle-float {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 700;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card-bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.menu-toggle-float:hover {
  border-color: var(--accent);
}

.menu-toggle-float:active {
  transform: scale(0.92);
}

@media (min-width: 721px) {
  .app-shell.sidebar-collapsed ~ .menu-toggle-float {
    display: flex;
  }
}

.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 59, 59, 0.16), rgba(255, 59, 59, 0.02));
  border: 1px solid var(--border);
  animation: fadeSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 3px var(--accent-dim);
  flex-shrink: 0;
  animation: fadeSlideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-title {
  font-size: 17px;
  font-weight: 800;
}

.hero-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.highlight-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.highlight-row::-webkit-scrollbar {
  display: none;
}

.highlight-chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  border-radius: 999px;
  background: var(--card-bg-soft);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  animation: fadeSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.highlight-chip:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.icon-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  font-size: 15px;
  background: linear-gradient(145deg, var(--accent) 0%, #b3121f 100%);
  box-shadow: 0 4px 14px -4px rgba(255, 59, 59, 0.65);
}

.icon-badge.sm {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 12px;
}

.icon-badge.soft {
  background: var(--card-bg-soft);
  border: 1px solid var(--border);
  box-shadow: none;
}

.app-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.12s ease, color 0.15s ease;
}

.app-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.6);
}

.app-row:last-child {
  border-bottom: none;
}

.app-row:hover {
  color: var(--accent);
  transform: translateX(2px);
}

.card:nth-of-type(1) {
  animation-delay: 0.02s;
}
.card:nth-of-type(2) {
  animation-delay: 0.06s;
}
.card:nth-of-type(3) {
  animation-delay: 0.1s;
}
.card:nth-of-type(4) {
  animation-delay: 0.14s;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 6px;
  border-radius: 999px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card-bg-soft);
  width: 100%;
  text-align: left;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item.active {
  background: linear-gradient(135deg, #ff5c5c, var(--accent) 65%);
  border-color: transparent;
  color: #170809;
  box-shadow: 0 8px 20px -8px rgba(255, 59, 59, 0.7);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 20px 90px;
  max-width: 640px;
}

.topbar {
  display: none;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.card-soft {
  background: var(--card-bg-soft);
  border-radius: var(--radius-md);
  padding: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.pill.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.pill.trial {
  background: rgba(107, 255, 176, 0.14);
  color: var(--success);
}

.pill.none {
  background: rgba(255, 92, 92, 0.14);
  color: var(--danger);
}

.big-number {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  margin: 14px 0 4px;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--text-dim);
  font-size: 13px;
}

.faint {
  color: var(--text-faint);
  font-size: 12px;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin: 12px 0 6px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 999px;
  border: none;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #ff5c5c, var(--accent) 60%);
  color: #170809;
  box-shadow: 0 10px 28px -10px rgba(255, 59, 59, 0.75);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.btn-secondary {
  background: var(--card-bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(255, 92, 92, 0.14);
  color: var(--danger);
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-icon {
  width: 48px;
  flex: none;
  padding: 14px 0;
}

.key-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
}

.key-box span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
  margin: 0 0 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--card-bg-soft);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}

.stat-box .value {
  font-size: 20px;
  font-weight: 800;
}

.stat-box .label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.step a:hover {
  text-decoration: underline;
}

.step-num {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.list-row:last-child {
  border-bottom: none;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

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

.faq-question {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  padding: 14px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.faq-answer {
  display: none;
  padding: 0 4px 14px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.faq-item.open .faq-answer {
  display: block;
}

.plan-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px 16px;
  margin-bottom: 12px;
  background: var(--card-bg-soft);
  animation: fadeSlideIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.plan-card.featured {
  border-color: var(--accent);
  background: linear-gradient(160deg, rgba(255, 59, 59, 0.14), var(--card-bg-soft) 60%);
  box-shadow: 0 8px 26px -10px rgba(255, 59, 59, 0.5);
}

.badge-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}

.plan-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.plan-price {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.plan-price span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-faint);
  margin-left: 2px;
}

.input,
select.input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 10px;
}

textarea.input {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

.tariff-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  cursor: pointer;
}

.tariff-option:hover {
  border-color: var(--accent);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge.paid {
  background: rgba(107, 255, 176, 0.14);
  color: var(--success);
}

.badge.pending {
  background: rgba(217, 255, 0, 0.14);
  color: var(--accent);
}

.badge.failed {
  background: rgba(255, 92, 92, 0.14);
  color: var(--danger);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show {
  opacity: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 900;
}

.modal {
  background: var(--card-bg);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--border);
  border-bottom: none;
}

.center-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-faint);
  font-size: 13px;
}

.bottom-nav {
  display: none;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}

.qr-wrap img,
.qr-wrap canvas {
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px;
}

@media (max-width: 720px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    display: none;
  }

  .main {
    max-width: none;
    padding: 16px 16px 90px;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0));
    z-index: 500;
  }

  .bottom-nav .nav-item {
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    padding: 8px 4px;
    margin-bottom: 0;
    text-align: center;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    box-shadow: none;
  }

  .bottom-nav .nav-icon {
    width: 20px;
    height: 20px;
  }

  .bottom-nav .nav-item.active {
    background: none;
    color: var(--accent);
  }
}

/* ---------- animations & polish ---------- */

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes backdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

@keyframes shimmer {
  from {
    background-position: -200px 0;
  }
  to {
    background-position: 200px 0;
  }
}

#main.page-enter {
  animation: fadeSlideIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card,
.card-soft {
  animation: fadeSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.nav-item {
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.nav-item:active {
  transform: scale(0.97);
}

.btn {
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.list-row,
.tariff-option,
.stat-box {
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tariff-option:active {
  transform: scale(0.985);
}

.pill-dot {
  animation: pulseGlow 1.8s ease-in-out infinite;
}

.modal-backdrop {
  animation: backdropIn 0.2s ease both;
}

.modal {
  animation: modalSlideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.center-loader {
  animation: pulseGlow 1.4s ease-in-out infinite;
}

/* ---------- brand / avatar ---------- */

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

.brand-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.panel-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card-bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 16px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.panel-switch:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- support chat ---------- */

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 420px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px 12px;
}

.chat-empty {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  margin-top: 40px;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.4;
  animation: fadeSlideIn 0.22s ease both;
  word-wrap: break-word;
}

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

.chat-bubble.from-admin {
  align-self: flex-start;
  background: var(--card-bg-soft);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble .chat-time {
  display: block;
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.chat-input-row textarea {
  flex: 1;
  min-height: 40px;
  max-height: 90px;
  resize: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
}

.chat-input-row button {
  width: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #170809;
  font-size: 16px;
  cursor: pointer;
}

.thread-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.thread-row:last-child {
  border-bottom: none;
}

.thread-row .snippet {
  color: var(--text-dim);
  font-size: 12px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
