:root {
  --ink: #0f2744;
  --muted: #5b738b;
  --line: #d5e0ea;
  --paper: rgba(255, 255, 255, 0.92);
  --teal: #0f766e;
  --teal-deep: #115e59;
  --teal-soft: #ccfbf1;
  --sky: #0e7490;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #047857;
  --ok-soft: #d1fae5;
  --shadow: 0 10px 28px rgba(15, 39, 68, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 68px;
  --font: "Vazirmatn", Tahoma, sans-serif;
  --app-max: 480px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #e7eef3;
  -webkit-tap-highlight-color: transparent;
}
body { overflow-x: hidden; }
button, a, input, select, textarea { font-family: inherit; }
img { max-width: 100%; height: auto; display: block; }
.hidden { display: none !important; }

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1000px 520px at 100% -8%, rgba(15, 118, 110, 0.16), transparent 55%),
    radial-gradient(820px 460px at -8% 18%, rgba(14, 116, 144, 0.12), transparent 50%),
    linear-gradient(180deg, #eef5f4 0%, #e8eef3 48%, #e4ebe9 100%);
}

.splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.splash-inner { text-align: center; display: grid; gap: 8px; }
.splash-mark {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--teal-deep);
  line-height: 1.15;
}
.splash-sub { margin: 0; color: var(--muted); font-size: 15px; }

.app {
  min-height: 100vh;
  max-width: var(--app-max);
  margin: 0 auto;
  padding: calc(58px + var(--safe-top)) 0 calc(var(--nav-h) + var(--safe-bottom) + 12px);
  background: transparent;
}
.app.sub-page { padding-bottom: calc(12px + var(--safe-bottom)); }
.app.sub-page .bottom-nav { display: none; }
.app.is-navigating .bottom-nav {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.bottom-nav {
  transition: opacity 0.15s ease;
}
.nav-item {
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.nav-item:active { transform: scale(0.96); }

.page-enter {
  animation: pageEnter 0.2s ease both;
}
.page-enter-tab {
  animation: pageEnterTab 0.18s ease both;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pageEnterTab {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.splash {
  animation: splashIn 0.28s ease both;
}
@keyframes splashIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.toast {
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.admin-tile,
.list-item,
.stat-card,
.panel {
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.list-item:active,
.stat-card:active {
  transform: scale(0.985);
}

@media (prefers-reduced-motion: reduce) {
  .page-enter,
  .page-enter-tab,
  .splash,
  .spinner {
    animation: none !important;
  }
  .btn,
  .nav-item,
  .admin-tile,
  .list-item,
  .bottom-nav,
  .toast,
  .panel,
  .stat-card {
    transition: none !important;
  }
}

.topbar {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  background: rgba(238, 245, 244, 0.86);
  border-bottom: 1px solid rgba(213, 224, 234, 0.9);
}
.topbar-inner {
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: calc(56px + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
}
.topbar-brand {
  display: flex;
  flex-direction: row;
  direction: ltr; /* icon then title — centered as a unit */
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  line-height: 1.2;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.topbar-brand strong {
  font-weight: 800;
  white-space: nowrap;
  line-height: 1.2;
  flex: 0 1 auto;
  direction: rtl;
  unicode-bidi: plaintext;
}
.topbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  color: var(--teal-deep);
}
.topbar-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  overflow: visible;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-btn svg { width: 22px; height: 22px; }
#header-back svg { transform: scaleX(-1); }
/* Keep grid slot when back is hidden — otherwise title shifts to the edge and clips */
#header-back.hidden {
  display: grid !important;
  visibility: hidden;
  pointer-events: none;
}
.topbar-spacer { width: 40px; height: 40px; }

.main {
  max-width: var(--app-max);
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 30;
  max-width: var(--app-max);
  margin: 0 auto;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active {
  color: var(--teal-deep);
  background: var(--teal-soft);
}
.app:has(#nav-admin:not(.hidden)) .nav-item {
  font-size: 10px;
  gap: 3px;
  padding: 5px 2px;
}
.app:has(#nav-admin:not(.hidden)) .nav-item svg {
  width: 20px;
  height: 20px;
}

.page-loading {
  min-height: 40vh;
  display: grid;
  place-items: center;
  gap: 12px;
  color: var(--muted);
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(15, 118, 110, 0.2);
  border-top-color: var(--teal);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 10px; }
.stack-lg { display: grid; gap: 18px; }

.hero { padding: 6px 2px 2px; }
.hero h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.home-user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 2px 2px;
}
.home-user-text {
  min-width: 0;
  flex: 1;
}
.home-user-text h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
  line-height: 1.35;
}
.home-user-text p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--teal), var(--teal-deep));
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.profile-avatar--photo {
  padding: 0;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(213, 224, 234, 0.95);
  box-shadow: none;
}
.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.page-intro {
  padding: 4px 2px 0;
}
.page-intro h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}
.page-intro p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--paper);
  border: 1px solid rgba(213, 224, 234, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.panel-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head .panel-title { margin: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card {
  background: var(--paper);
  border: 1px solid rgba(213, 224, 234, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
  display: grid;
  gap: 8px;
  min-height: 88px;
}
.stat-card.wide { grid-column: 1 / -1; }
.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.stat-value {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--teal-deep);
}
.stat-value.sm { font-size: 18px; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}
a.btn,
a.btn:hover,
a.btn:visited,
a.btn:active {
  text-decoration: none;
  color: inherit;
}
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn.is-loading {
  opacity: 0.65;
  pointer-events: none;
}
.btn-primary {
  background: linear-gradient(135deg, #0f766e, #0e7490);
  border-color: transparent;
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.28);
}
a.btn.btn-primary,
a.btn.btn-primary:hover,
a.btn.btn-primary:visited {
  color: #fff !important;
}
.btn-secondary,
.btn-ghost {
  background: #fff;
  border-color: #b7c7d6;
  color: var(--ink) !important;
  box-shadow: 0 2px 8px rgba(15, 39, 68, 0.06);
}
.btn-ghost:active,
.btn-secondary:active {
  background: #f1f5f9;
}
.btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff !important;
}
.btn-warn {
  background: #d97706;
  border-color: transparent;
  color: #fff !important;
}
.btn-block { width: 100%; }
.btn-sm {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 12px;
}
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.actions {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.field { display: grid; gap: 8px; }
.field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.field .hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: #5eead4;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.7;
}
.form-grid { display: grid; gap: 14px; }
.check-grid { display: grid; gap: 10px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.check-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
  flex-shrink: 0;
}
.range-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}
.range-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e8eef2;
  color: var(--muted);
  width: fit-content;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-teal { background: var(--teal-soft); color: var(--teal-deep); }

.list { display: grid; gap: 12px; }
.list-item {
  width: 100%;
  text-align: right;
  background: var(--paper);
  border: 1px solid rgba(213, 224, 234, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 13px;
  display: grid;
  gap: 8px;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.list-item h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
}
.list-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.meta-row { display: grid; gap: 10px; }
.meta-row .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.meta-row .row:last-child { border-bottom: 0; padding-bottom: 0; }
.meta-row .row:first-child { padding-top: 0; }
.meta-row .k {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.meta-row .v {
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  word-break: break-word;
}
.kv-ltr { direction: ltr; unicode-bidi: plaintext; }

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  display: grid;
  gap: 10px;
  justify-items: center;
}
.empty-soft {
  background: var(--paper);
  border: 1px solid rgba(213, 224, 234, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 20px;
}
.empty strong {
  color: var(--ink);
  font-size: 16px;
}
.empty p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  max-width: 28ch;
}

.notice {
  padding: 14px;
  border-radius: 14px;
  background: var(--warn-soft);
  color: #92400e;
  font-size: 13px;
  line-height: 1.7;
  font-weight: 600;
}
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.notice-danger { background: var(--danger-soft); color: var(--danger); }
.notice-info { background: #e0f2fe; color: #075985; }

.gate, .tg-blocked {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
}
.gate-inner, .tg-blocked-inner {
  max-width: 360px;
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
  display: grid;
  gap: 14px;
}
.gate-inner h1, .tg-blocked-inner h1 {
  margin: 0;
  font-size: 22px;
}
.gate-inner p, .tg-blocked-inner p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.review-box {
  background: #f0fdfa;
  border: 1px dashed #5eead4;
  border-radius: 14px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}
.review-panel .panel-head {
  margin-bottom: 10px;
}

.file-box { display: grid; gap: 10px; }
.file-box input[type="file"] {
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fff;
}
.preview-img {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  max-height: 280px;
  object-fit: contain;
  background: #f8fafc;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.admin-tab {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.admin-tab.active {
  background: var(--teal-soft);
  border-color: #99f6e4;
  color: var(--teal-deep);
}

.price {
  font-weight: 800;
  color: var(--teal-deep);
  direction: ltr;
  unicode-bidi: plaintext;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(15, 39, 68, 0.94);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

.radio-grid { display: grid; gap: 10px; }
.radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.radio-item input {
  accent-color: var(--teal);
  width: 18px;
  height: 18px;
}

.status-pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.status-ACTIVE, .status-APPROVED, .status-PAID { background: var(--ok-soft); color: var(--ok); }
.status-PENDING, .status-ASSIGNED, .status-SUBMITTED { background: var(--warn-soft); color: var(--warn); }
.status-INACTIVE, .status-REJECTED, .status-EXPIRED, .status-SUSPENDED { background: var(--danger-soft); color: var(--danger); }
.status-NEW, .status-PAUSED { background: #e0f2fe; color: #075985; }

.copy-block {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

/* Admin home — compact categorized 2-col menu */
.admin-home { gap: 16px; }
.hero-compact h1 { font-size: 22px; }
.hero-compact p { margin-top: 4px; font-size: 13px; }

.admin-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.admin-stat {
  background: var(--paper);
  border: 1px solid rgba(213, 224, 234, 0.95);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
  display: grid;
  gap: 2px;
  box-shadow: var(--shadow);
}
.admin-stat-n {
  font-size: 18px;
  font-weight: 800;
  color: var(--teal-deep);
  line-height: 1.2;
}
.admin-stat-l {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.admin-section { display: grid; gap: 8px; }
.admin-section-title {
  margin: 0;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.admin-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.admin-tile {
  appearance: none;
  width: 100%;
  min-height: 84px;
  margin: 0;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(213, 224, 234, 0.95);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: right;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  color: inherit;
  transition: transform 0.12s ease, background 0.12s ease;
}
.admin-tile:active {
  transform: scale(0.98);
  background: #f0fdfa;
}
.admin-tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.admin-tile-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}
.admin-tile-desc {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.45;
}
.admin-tile-badge {
  flex-shrink: 0;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e8eef2;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.admin-tile-badge.is-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.admin-menu-grid .admin-tile:only-child {
  grid-column: 1 / -1;
}

.admin-danger-card {
  border-color: rgba(185, 28, 28, 0.25);
  background: linear-gradient(180deg, rgba(254, 226, 226, 0.45), var(--paper));
}
.admin-reset-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  font-weight: 600;
}
.reset-steps {
  display: flex;
  gap: 8px;
  align-items: center;
}
.reset-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  background: #e8eef2;
  color: var(--muted);
}
.reset-dot.on {
  background: var(--danger-soft);
  color: var(--danger);
}
