:root {
  color-scheme: dark;
  --bg: #0c0f15;
  --surface: #131720;
  --surface-2: #1a202c;
  --border: #252c3b;
  --border-hover: #364156;
  --text: #eef1f6;
  --muted: #8b95a8;
  --accent: #8b95f6;
  --accent-ink: #0e1222;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;

  accent-color: var(--accent);
  scrollbar-color: #364156 #131720;
}

@supports not (scrollbar-color: auto) {
  html {
    scrollbar-width: auto;
  }
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  ::-webkit-scrollbar-track {
    background: var(--surface);
  }
  ::-webkit-scrollbar-thumb {
    background: #364156;
    border-radius: 6px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-block-end: 84px;
  min-height: 100dvh;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

.container {
  max-width: 640px;
  margin-inline: auto;
  padding-inline: 14px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(12, 15, 21, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 58px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.pill-btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.pill-btn:hover {
  border-color: var(--border-hover);
}

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

/* Search */
.search-wrap {
  margin-block: 14px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  inset-inline-start: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px 10px 42px;
  padding-inline-start: 42px;
  padding-inline-end: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: max(1rem, 1em);
}

.search-input::placeholder {
  color: var(--muted);
}

/* Hero */
.hero {
  padding: 20px 6px 14px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 4.5vw, 1.75rem);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.hero h1 span {
  color: var(--accent);
}

.hero p {
  margin: 0 auto;
  max-width: 44ch;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Launch Banner */
.tier-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  margin-block: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

.tier-tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(139, 149, 246, 0.14);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
}

/* Category Quick Grid */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-block-end: 22px;
}

.quick-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}

.quick-tile:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.tile-ico {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.tile-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}

/* Section Headers & Filters */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-block: 18px 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-end: 14px;
}

.chip {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

/* Cards & Plans */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-block-end: 12px;
}

.plan-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.plan-info h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
  font-weight: 700;
}

.plan-meta {
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.plan-buy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: none;
}

.price-main {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.price-old {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: line-through;
  margin-inline-end: 5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--border-hover);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.btn.sm {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-block-end: 14px;
}

.form-group label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}

.input,
.select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: max(1rem, 1em);
}

.input:focus-visible,
.select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Copy Box */
.copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-block: 8px;
}

.copy-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  direction: ltr;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Orders & Progress */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.badge.ok {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.3);
}

.badge.warn {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.3);
}

.badge.danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}

.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-block: 8px;
}

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

.ovpn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-block-start: 10px;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 30;
  background: rgba(12, 15, 21, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}

.bottom-nav-inner {
  max-width: 640px;
  margin-inline: auto;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: 64px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
}

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

.nav-item svg {
  width: 21px;
  height: 21px;
}

/* Native Modal Dialogs */
dialog {
  margin: auto;
  width: min(94vw, 460px);
  max-height: 90dvh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  overflow: auto;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(5, 7, 11, 0.72);
  backdrop-filter: blur(3px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h1,
.dialog-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.dialog-body {
  padding: 16px;
}

.icon-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}

/* Radio options for Protocol choice */
.radio-cards {
  display: grid;
  gap: 10px;
  margin-block: 12px 16px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}

.radio-card input {
  margin-top: 4px;
}

/* Admin Table / Row */
.admin-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* Status Toast */
.toast {
  position: fixed;
  top: 68px;
  inset-inline: 16px;
  margin-inline: auto;
  max-width: 420px;
  z-index: 60;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.toast[hidden] {
  display: none;
}

.qr-box {
  display: grid;
  place-items: center;
  padding: 14px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  width: fit-content;
  margin-inline: auto;
  margin-block: 10px;
}

.qr-box img {
  width: 196px;
  height: 196px;
  display: block;
}

[hidden] {
  display: none !important;
}
