@font-face {
  font-family: Vazirmatn;
  src: url("fonts/Vazirmatn[wght].woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg-gradient: radial-gradient(circle at top right, #eef2ff 0, #f8fafc 36%, #eef2f7 100%);
  --card-bg: rgba(255, 255, 255, 0.86);
  --modal-bg: #ffffff;
  --text-primary: #111827;
  --text-secondary: #64748b;
  --border: rgba(148, 163, 184, 0.28);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
  --primary: #4f46e5;
  --primary-strong: #3730a3;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --muted: #e5e7eb;
  --focus: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

[data-theme="dark"] {
  --bg-gradient: radial-gradient(circle at top right, #1e1b4b 0, #0f172a 40%, #020617 100%);
  --card-bg: rgba(15, 23, 42, 0.82);
  --modal-bg: #111827;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --border: rgba(148, 163, 184, 0.26);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  --muted: #1f2937;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  padding: 32px 16px 104px;
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.container {
  width: min(520px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 32px;
}

.hero-header {
  text-align: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.86rem;
}

h1,
h2,
h3,
p {
  margin-block-start: 0;
}

h1 {
  margin-block-end: 10px;
  font-size: clamp(1.8rem, 6vw, 2.5rem);
}

#main-instruction {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.8;
}

.auth-status-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.34);
}

[data-theme="dark"] .auth-status-card {
  background: rgba(15, 23, 42, 0.4);
}

.auth-status-card strong {
  display: block;
  margin-bottom: 4px;
}

.auth-status-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.7;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(217, 119, 6, 0.12);
}

.status-dot.success {
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(5, 150, 105, 0.12);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.12);
}

.platform-buttons {
  position: relative;
  display: grid;
  gap: 14px;
}

.initial-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  color: var(--text-secondary);
}

.initial-loader p {
  margin: 0;
}

.loader-spinner,
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid currentColor;
  border-top-color: transparent;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.platform-btn,
.action-button,
.outline-button,
.small-action-btn,
.installer-platform {
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.interactive-scale:hover,
.platform-btn:hover:not(:disabled),
.action-button:hover:not(:disabled),
.outline-button:hover:not(:disabled),
.installer-platform:hover:not(:disabled) {
  transform: translateY(-1px);
}

.platform-btn {
  min-height: 64px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--modal-bg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  text-align: right;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
}

.platform-btn:disabled {
  opacity: 0.66;
  cursor: not-allowed;
  transform: none;
}

.platform-btn.logged-in {
  border-color: rgba(5, 150, 105, 0.55);
  background: rgba(5, 150, 105, 0.1);
}

.platform-btn.disabled-by-403 {
  border-color: rgba(220, 38, 38, 0.38);
  background: rgba(220, 38, 38, 0.08);
}

/* [FIX] حالت در حال بارگذاری — وقتی auth کامل شده ولی system-status هنوز نرسیده */
.platform-btn.status-pending {
  opacity: 0.78;
}

.platform-btn.status-pending .platform-name {
  opacity: 0.65;
}

.platform-btn.status-pending::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-secondary, #64748b);
  margin-inline-start: 6px;
  animation: pulse-dot 1.2s ease-in-out infinite;
  vertical-align: middle;
  flex: 0 0 auto;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.platform-logo,
.initials-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: contain;
  flex: 0 0 auto;
}

.initials-logo {
  display: inline-grid;
  place-items: center;
  background: var(--muted);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 800;
}

.platform-name {
  flex: 1;
  font-weight: 750;
}

.success-icon,
.lock-icon {
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  place-items: center;
  font-weight: 900;
}

.success-icon {
  color: #ffffff;
  background: var(--success);
}

.lock-icon {
  background: var(--muted);
}

.platform-btn.logged-in .success-icon,
.platform-btn.locked .lock-icon {
  display: grid;
}

.btn-svg,
.support-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

img.support-icon {
  display: block;
  object-fit: contain;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-block: 6px;
}

.section-divider::before,
.section-divider::after {
  content: '';
  height: 1px;
  flex: 1;
  background: var(--border);
}

.subscription-lock {
  border: 1px dashed rgba(220, 38, 38, 0.42);
  border-radius: 24px;
  padding: 24px;
  text-align: center;
  background: rgba(220, 38, 38, 0.06);
}

.lock-illustration {
  font-size: 3rem;
  margin-bottom: 10px;
}

.subscription-lock h2 {
  margin-bottom: 8px;
  font-size: 1.25rem;
}

.subscription-lock p {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 18px;
}

.action-button,
.external-action,
.outline-button,
.small-action-btn {
  min-height: 48px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
}

.action-button,
.external-action {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #ffffff;
  border: 1px solid transparent;
}

.outline-button,
.small-action-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding-inline: 16px;
}

.small-action-btn {
  min-height: 36px;
  border-radius: 12px;
  white-space: nowrap;
}

.action-button:disabled,
.outline-button:disabled,
.small-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.action-button .spinner,
.outline-button .spinner,
.small-action-btn .spinner {
  display: none;
}

.loading .button-text,
.loading>span:not(.spinner) {
  opacity: 0.72;
}

.loading .spinner {
  display: inline-block;
}

.support-links {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 10px;
  border-radius: 24px;
  backdrop-filter: blur(18px);
  z-index: 30;
}

.support-link {
  min-width: 76px;
  min-height: 54px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 16px;
  display: grid;
  place-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.78rem;
}

.support-link:hover {
  background: rgba(148, 163, 184, 0.14);
}

.theme-toggle-btn {
  position: fixed;
  top: 18px;
  left: 18px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 40;
}

.theme-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000000;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10px;
  border-radius: 18px;
  padding: 14px 14px 13px 16px;
  background: var(--modal-bg);
  background: color-mix(in srgb, var(--modal-bg) 94%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateY(-12px) scale(0.985);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  line-height: 1.7;
  pointer-events: auto;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  inset-block: 12px;
  inset-inline-start: 0;
  width: 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: .9;
}

.toast.visible {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast-content {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.toast-title {
  display: block;
  color: var(--text-primary);
  font-size: .92rem;
  font-weight: 900;
}

.toast-message {
  margin: 0;
  color: var(--text-secondary);
  font-size: .86rem;
  font-weight: 700;
}

.toast-code {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: .72rem;
  direction: ltr;
  text-align: left;
  opacity: .68;
}

.toast-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(148, 163, 184, .14);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.toast.success {
  color: #059669;
  border-color: rgba(5, 150, 105, 0.38);
}

.toast.warning {
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.42);
}

.toast.error {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.42);
}

.toast.info {
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.34);
}

.modal-overlay,
.app-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.modal-overlay.active,
.app-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-overlay {
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-content {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.22rem;
}

.close-button,
.app-close-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.55rem;
  line-height: 1;
}

.modal-help {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 16px;
}

.success-popup {
  text-align: center;
}

.success-popup .modal-header {
  text-align: right;
}

.success-icon-large {
  display: inline-grid;
  place-items: center;
  color: var(--success);
  margin-bottom: 12px;
}

.privacy-text-box {
  min-height: 180px;
  max-height: 310px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary);
  line-height: 1.95;
  white-space: pre-wrap;
  margin-bottom: 16px;
}

.installer-container {
  display: grid;
  gap: 12px;
}

.installer-platform {
  width: 100%;
  min-height: 72px;
  text-align: right;
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: transparent;
  color: var(--text-primary);
  padding: 14px 16px;
}

.installer-platform span {
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.installer-platform.selected {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
}

.form-step {
  display: none;
}

.form-step.active {
  display: grid;
  gap: 16px;
}

.form-group {
  display: grid;
  gap: 8px;
}

.form-group label {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

input {
  width: 100%;
  height: 50px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  padding: 0 14px;
}

.captcha-box {
  display: grid;
  gap: 12px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 12px;
}

.captcha-box img {
  max-width: 100%;
  border-radius: 14px;
  background: #ffffff;
}

.otp-instructions,
.otp-phone-display,
.message {
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.8;
  margin: 0;
}

.otp-phone-display {
  font-weight: 800;
  direction: ltr;
  color: var(--text-primary);
}

.otp-container {
  display: flex;
  justify-content: center;
  gap: 8px;
  direction: ltr;
}

.otp-input {
  width: 42px;
  height: 52px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  padding: 0;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.shake {
  animation: shake 0.42s ease;
}

.app-modal-overlay {
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.app-modal-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: var(--modal-bg);
  border-bottom: 1px solid var(--border);
}

.app-modal-title {
  font-weight: 900;
}

.app-frame-container {
  min-height: 0;
}

.modal-iframe-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--modal-bg);
}

.iframe-state {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(217, 119, 6, 0.12);
  color: var(--text-primary);
}

.iframe-state p {
  margin: 0;
}

.hidden,
.hidden-by-subscription,
[hidden] {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shake {

  10%,
  90% {
    transform: translateX(-1px);
  }

  20%,
  80% {
    transform: translateX(2px);
  }

  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }

  40%,
  60% {
    transform: translateX(4px);
  }
}

@media (max-width: 640px) {
  body {
    padding: 80px 12px 106px;
  }

  .container {
    padding: 22px;
    border-radius: 24px;
  }

  .auth-status-card {
    grid-template-columns: auto 1fr;
  }

  .auth-status-card .small-action-btn {
    grid-column: 1 / -1;
  }

  .support-links {
    width: calc(100vw - 16px);
    justify-content: space-between;
    gap: 2px;
  }

  .support-link {
    min-width: auto;
    width: 24%;
  }

  .otp-input {
    width: 38px;
  }
}

/* v5.1 side-page modal fixes: dashboard/matching are full-screen app pages, not dimmed dialogs. */
body.side-modal-open {
  overflow: hidden;
  padding-right: 0;
}

.app-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
  padding: 0;
  background: var(--modal-bg);
  backdrop-filter: none;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.app-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.app-modal-header {
  position: relative;
  z-index: 2;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: var(--modal-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.app-frame-container {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--modal-bg);
}

.modal-iframe-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: var(--modal-bg);
}

.iframe-state[hidden] {
  display: none !important;
}

.iframe-state:not([hidden]) {
  position: relative;
  z-index: 2;
}


/* v5.2 iframe page reliability fixes */
.app-modal-overlay {
  grid-template-rows: 64px minmax(0, 1fr);
}

.app-modal-overlay>.iframe-state:not([hidden]) {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  min-height: 52px;
  z-index: 5;
}

.app-modal-overlay>.app-frame-container {
  grid-row: 2;
  height: calc(100dvh - 64px);
}

.modal-iframe-frame {
  height: calc(100dvh - 64px);
}


/* === Shiraze v6 UI cleanup: keep original product UI, remove technical noise === */
:root {
  --platform-p24: #4f46e5;
  --platform-drdr: #38bdf8;
  --platform-doctoreto: #ef4444;
  --app-soft-bg: #eef2ff;
  --app-card-bg: rgba(255, 255, 255, .86);
  --app-border: rgba(226, 232, 240, .92);
  --app-radius-xl: 32px;
  --app-radius-lg: 24px;
  --app-radius-md: 18px;
  --app-shadow-soft: 0 24px 70px rgba(79, 70, 229, .12);
  --app-spring: cubic-bezier(.34, 1.56, .64, 1);
}

body {
  background: radial-gradient(circle at 50% 8%, #f8fbff 0, #eef2ff 42%, #eaf0fb 100%);
}

.container {
  border-radius: var(--app-radius-xl);
  box-shadow: var(--app-shadow-soft);
  border-color: var(--app-border);
}

.eyebrow {
  color: var(--primary);
  font-size: .82rem;
  font-weight: 800;
}

.auth-status-card.hidden {
  display: none !important;
}

.auth-status-card.auth-error-visible {
  display: grid;
  background: rgba(255, 255, 255, .82);
  border-color: rgba(239, 68, 68, .25);
}

.auth-status-card:not(.auth-error-visible) {
  display: none;
}

.auth-status-card.auth-error-visible #auth-status-title {
  color: var(--danger);
}

.auth-status-card.auth-error-visible #auth-status-message {
  color: var(--text-secondary);
}

#retry-auth-btn:not(.hidden) {
  background: #fff;
  border: 1px solid rgba(239, 68, 68, .25);
  color: var(--danger);
}

.initial-loader {
  min-height: 0;
  padding: 8px 0;
}

.initial-loader.hidden {
  display: none !important;
}

.initial-loader p {
  font-size: .84rem;
}

.platform-btn {
  border-radius: 20px;
  min-height: 64px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, .045);
  background: rgba(255, 255, 255, .92);
}

.platform-btn:not(:disabled):active {
  transform: scale(.985);
}

.platform-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 auto;
}

.platform-btn.success-state,
.platform-btn.connected,
.platform-btn.success,
.platform-btn[data-connected="true"] {
  border-color: rgba(5, 150, 105, .42);
  background: linear-gradient(135deg, rgba(236, 253, 245, .98), rgba(240, 253, 244, .88));
  color: #15803d;
}

#doctoreto-btn:not(:disabled) {
  border-color: rgba(239, 68, 68, .20);
}

#drdr-btn:not(:disabled) {
  border-color: rgba(56, 189, 248, .22);
}

#open-dashboard-btn,
#open-matching-btn {
  font-weight: 900;
}

.support-links {
  border-radius: 22px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 18px 45px rgba(15, 23, 42, .08);
  border: 1px solid rgba(226, 232, 240, .88);
}

.support-link {
  border-radius: 16px;
}

.modal-content {
  border-radius: 30px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, .28);
}

.close-button,
.app-close-btn {
  border-radius: 18px;
}

.action-button {
  border-radius: 18px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  box-shadow: 0 16px 34px rgba(79, 70, 229, .22);
}

.outline-button {
  border-radius: 18px;
}

/* Side iframe pages keep the user's original fullscreen sheet feel */
.app-modal-overlay {
  background: #f8fafc;
}

.app-modal-header {
  min-height: 70px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid rgba(226, 232, 240, .95);
}

.app-modal-title {
  font-weight: 900;
}

.app-frame-container {
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
}

.modal-iframe-frame {
  background: transparent;
}

@media (max-width: 540px) {
  body {
    padding: 22px 14px 92px;
    place-items: start center;
  }

  .container {
    padding: 26px 22px;
    width: min(420px, 100%);
  }

  .hero-header {
    margin-bottom: 18px;
  }

  h1 {
    font-size: 2.05rem;
  }

  .platform-btn {
    min-height: 58px;
    border-radius: 18px;
    padding: 10px 14px;
  }

  .platform-logo {
    width: 36px;
    height: 36px;
  }

  .support-links {
    bottom: 14px;
    width: min(270px, calc(100% - 32px));
  }
}

/* === v6.1 final mobile-first cleanup based on the familiar Shiraze UI === */
:root {
  --ui-bg-1: #f8fbff;
  --ui-bg-2: #eef2ff;
  --ui-card: rgba(255, 255, 255, 0.92);
  --ui-card-solid: #ffffff;
  --ui-text: #172033;
  --ui-muted: #69758a;
  --ui-line: rgba(209, 213, 219, 0.78);
  --ui-primary: #5546d9;
  --ui-primary-strong: #4033b8;
  --ui-success: #4aa66a;
  --ui-soft-danger: #fff7f7;
  --ui-danger-line: rgba(239, 68, 68, 0.22);
  --ui-radius-card: 28px;
  --ui-radius-btn: 17px;
  --ui-shadow: 0 22px 70px rgba(79, 70, 229, 0.14);
}

:root[data-theme="dark"] {
  --bg-gradient: radial-gradient(circle at top, #252a3a 0, #171b28 55%, #10131e 100%);
  --card-bg: rgba(31, 36, 52, 0.94);
  --modal-bg: #23283a;
  --text-primary: #f8fafc;
  --text-secondary: #c4cad7;
  --border: rgba(226, 232, 240, 0.13);
  --muted: #343a4f;
  --ui-card: rgba(31, 36, 52, 0.94);
  --ui-card-solid: #23283a;
  --ui-text: #f8fafc;
  --ui-muted: #c4cad7;
  --ui-line: rgba(226, 232, 240, 0.13);
  --ui-soft-danger: rgba(239, 68, 68, 0.10);
  --ui-danger-line: rgba(239, 68, 68, 0.25);
  --ui-shadow: 0 22px 70px rgba(0, 0, 0, 0.30);
}

html {
  min-height: 100%;
}

body {
  width: 100%;
  min-height: 100dvh;
  padding: 22px 14px 92px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: radial-gradient(circle at 50% 0%, var(--ui-bg-1), var(--ui-bg-2) 68%);
  overflow-x: hidden;
}

:root[data-theme="dark"] body {
  background: var(--bg-gradient);
}

.container {
  width: min(100%, 390px);
  margin: 0 auto;
  padding: 24px 20px;
  border-radius: var(--ui-radius-card);
  background: var(--ui-card);
  border: 1px solid var(--ui-line);
  box-shadow: var(--ui-shadow);
  backdrop-filter: blur(20px);
}

.hero-header {
  margin-bottom: 20px;
  text-align: center;
}

.hero-header .eyebrow {
  display: none !important;
}

h1 {
  margin: 0 0 10px;
  color: var(--ui-text);
  font-size: clamp(2rem, 10vw, 2.45rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}

#main-instruction {
  color: var(--ui-muted);
  font-size: 0.92rem;
  line-height: 1.9;
}

.auth-status-card:not(.auth-error-visible) {
  display: none !important;
}

.auth-status-card.auth-error-visible {
  grid-template-columns: 1fr auto;
  padding: 13px 14px;
  border-radius: 18px;
  background: var(--ui-soft-danger);
  border-color: var(--ui-danger-line);
}

.auth-status-card .status-dot {
  display: none;
}

.auth-status-card strong {
  color: #be123c;
  font-size: 0.95rem;
}

.auth-status-card p {
  font-size: 0.82rem;
}

#retry-auth-btn:not(.hidden) {
  grid-column: 1 / -1;
  width: 100%;
  color: #be123c;
  background: #fff;
}

.initial-loader {
  min-height: 0;
  padding: 0;
  color: var(--ui-muted);
  font-size: 0.82rem;
}

.initial-loader .loader-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.platform-buttons {
  gap: 12px;
}

.platform-btn {
  min-height: 58px;
  padding: 9px 12px;
  border-radius: 17px;
  background: var(--ui-card-solid);
  border: 1px solid var(--ui-line);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.045);
  gap: 12px;
  color: var(--ui-text);
}

.platform-btn:disabled {
  opacity: 1;
  background: rgba(255, 255, 255, 0.72);
  color: #8b95a8;
  border-color: rgba(203, 213, 225, 0.62);
  box-shadow: none;
}

:root[data-theme="dark"] .platform-btn:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(248, 250, 252, 0.54);
}

.platform-btn.unavailable,
.platform-btn.disabled-by-403 {
  background: rgba(255, 255, 255, 0.70);
  border-color: rgba(203, 213, 225, 0.72);
  color: #778197;
}

#doctoreto-btn.unavailable,
#drdr-btn.unavailable,
.platform-btn.disabled-by-403 {
  border-color: rgba(203, 213, 225, 0.72);
}

.platform-logo,
.initials-logo {
  width: 36px;
  height: 36px;
  border-radius: 13px;
}

.platform-name {
  font-size: 0.95rem;
  font-weight: 850;
  text-align: right;
}

.success-icon {
  width: 28px;
  height: 28px;
  font-size: 1rem;
}

.lock-icon,
.soft-status-icon,
.platform-btn.locked .lock-icon {
  display: none !important;
}

.platform-btn.logged-in {
  background: linear-gradient(135deg, rgba(236, 253, 245, .96), rgba(240, 253, 244, .90));
  border-color: rgba(74, 166, 106, .45);
  color: #2f8a49;
}

:root[data-theme="dark"] .platform-btn.logged-in {
  background: rgba(34, 197, 94, 0.14);
  color: #a7f3d0;
}

.coming-soon {
  color: #8b95a8;
}

.section-divider {
  margin-block: 4px;
  font-size: 0.78rem;
  color: var(--ui-muted);
}

.section-divider::before,
.section-divider::after {
  opacity: 0.55;
}

.subscription-lock {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--ui-line);
}

.lock-illustration {
  font-size: 2rem;
  color: var(--ui-primary);
}

.subscription-lock h2 {
  font-size: 1.06rem;
  color: var(--ui-text);
}

.subscription-lock p {
  font-size: 0.9rem;
}

.action-button,
.external-action,
.outline-button,
.small-action-btn {
  border-radius: 17px;
}

.action-button,
.external-action {
  background: linear-gradient(135deg, var(--ui-primary), var(--ui-primary-strong));
}

.support-links {
  width: min(270px, calc(100% - 32px));
  bottom: 14px;
  left: 50%;
  padding: 8px;
  gap: 3px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.90);
  border-color: rgba(226, 232, 240, 0.82);
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] .support-links {
  background: rgba(31, 36, 52, 0.94);
}

.support-link {
  min-width: 0;
  width: 25%;
  min-height: 46px;
  border-radius: 14px;
  font-size: 0.72rem;
}

.support-icon {
  width: 20px;
  height: 20px;
}

.theme-toggle-btn {
  top: 14px;
  left: 14px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--ui-card-solid);
  color: var(--ui-text);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.theme-icon {
  width: 20px;
  height: 20px;
}

.modal-content {
  width: min(100%, 390px);
  padding: 22px 20px;
  border-radius: 24px;
}

.modal-header {
  margin-bottom: 14px;
}

.modal-header h2 {
  font-size: 1.35rem;
}

.modal-help {
  font-size: 0.94rem;
}

.close-button,
.app-close-btn {
  border-radius: 14px;
  color: var(--ui-text);
}

.privacy-text-box {
  max-height: 52dvh;
  font-size: 0.9rem;
  background: rgba(241, 245, 249, .62);
}

.installer-platform {
  min-height: 62px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .78);
  padding: 13px 14px;
}

.installer-platform strong {
  font-size: 1rem;
}

.installer-platform span {
  font-size: 0.82rem;
}

.installer-platform.selected {
  background: rgba(99, 102, 241, .11);
}

.app-modal-header {
  min-height: 58px;
  padding: 10px 14px;
}

.app-modal-title {
  font-size: 0.95rem;
}

.app-modal-overlay {
  grid-template-rows: 58px minmax(0, 1fr);
}

.app-modal-overlay>.app-frame-container {
  height: calc(100dvh - 58px);
}

.modal-iframe-frame {
  height: calc(100dvh - 58px);
}

.app-modal-overlay>.iframe-state:not([hidden]) {
  top: 58px;
}

.iframe-state {
  font-size: 0.88rem;
  text-align: center;
}

@media (min-width: 768px) {
  body {
    align-items: center;
    padding: 32px 16px 104px;
  }

  .container {
    width: min(420px, 100%);
    padding: 30px 26px;
  }
}

@media (max-width: 380px) {
  body {
    padding-inline: 10px;
  }

  .container {
    padding: 20px 16px;
    border-radius: 24px;
  }

  h1 {
    font-size: 1.9rem;
  }

  .platform-btn {
    min-height: 54px;
  }

  .platform-logo,
  .initials-logo {
    width: 32px;
    height: 32px;
  }

  .platform-name {
    font-size: 0.9rem;
  }
}


/* === v6.2 login resilience cleanup === */
.platform-logo.asset-load-failed {
  display: none !important;
}

.platform-btn:disabled .platform-name {
  opacity: 0.82;
}

.initial-loader:not(.hidden)+.platform-btn,
.initial-loader:not(.hidden)~.platform-btn {
  pointer-events: none;
}

.auth-status-card.auth-error-visible {
  grid-template-columns: 1fr;
  text-align: center;
}

#retry-auth-btn:not(.hidden) {
  min-height: 42px;
  font-weight: 900;
}

:root[data-theme="dark"] #retry-auth-btn:not(.hidden) {
  background: #f8fafc;
  color: #991b1b;
  border-color: rgba(248, 250, 252, 0.24);
}


/* === v6.3 visual correction: preserve familiar UI, fix dark modal/readability === */
:root {
  --modal-text-strong: var(--ui-text, var(--text-primary));
  --modal-text-muted: var(--ui-muted, var(--text-secondary));
  --modal-card-bg: var(--ui-card-solid, var(--modal-bg));
  --modal-line: var(--ui-line, var(--border));
}

:root[data-theme="dark"] {
  --modal-text-strong: #f8fafc;
  --modal-text-muted: #d6dbea;
  --modal-card-bg: #252a3d;
  --modal-line: rgba(226, 232, 240, 0.18);
}

:root[data-theme="dark"] .modal-content,
:root[data-theme="dark"] .success-popup,
:root[data-theme="dark"] #platform-select-modal .modal-content,
:root[data-theme="dark"] #privacy-modal .modal-content,
:root[data-theme="dark"] #login-modal .modal-content,
:root[data-theme="dark"] #system-status-modal .modal-content {
  background: #23283a;
  color: var(--modal-text-strong);
  border-color: rgba(129, 140, 248, 0.22);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.40), 0 0 0 1px rgba(129, 140, 248, 0.12) inset;
}

:root[data-theme="dark"] .modal-header h2,
:root[data-theme="dark"] .modal-content h2,
:root[data-theme="dark"] .modal-content strong,
:root[data-theme="dark"] .modal-content label {
  color: #f8fafc;
}

:root[data-theme="dark"] .modal-help,
:root[data-theme="dark"] .modal-content p,
:root[data-theme="dark"] .installer-platform span,
:root[data-theme="dark"] .form-group label,
:root[data-theme="dark"] .otp-instructions,
:root[data-theme="dark"] .message {
  color: var(--modal-text-muted);
}

.close-button,
.app-close-btn {
  display: inline-grid;
  place-items: center;
  line-height: 1;
  font-weight: 900;
}

:root[data-theme="dark"] .close-button,
:root[data-theme="dark"] .app-close-btn {
  background: rgba(255, 255, 255, 0.07);
  color: #f8fafc;
  border-color: rgba(226, 232, 240, 0.22);
}

:root[data-theme="dark"] .close-button:hover,
:root[data-theme="dark"] .app-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.privacy-text-box {
  color: var(--modal-text-strong);
  background: rgba(248, 250, 252, 0.72);
}

:root[data-theme="dark"] .privacy-text-box {
  background: rgba(15, 18, 30, 0.55);
  color: #f1f5f9;
  border-color: rgba(226, 232, 240, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

:root[data-theme="dark"] .privacy-text-box::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.56);
}

#platform-select-modal .modal-content {
  max-width: 540px;
}

.installer-container {
  gap: 12px;
}

.installer-platform {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 74px;
  border-radius: 18px;
  text-align: right;
}

.installer-logo-wrap {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-grid;
  place-items: center;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.88);
  overflow: hidden;
}

.installer-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.installer-logo-fallback {
  color: var(--text-secondary);
  font-weight: 900;
  font-size: .82rem;
}

.installer-text {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.installer-text strong {
  color: var(--modal-text-strong);
  font-size: 1.02rem;
}

.installer-text span {
  color: var(--modal-text-muted);
  font-size: .84rem;
  line-height: 1.75;
}

.installer-platform.selected {
  background: rgba(99, 102, 241, 0.10);
  border-color: rgba(99, 102, 241, 0.58);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
}

:root[data-theme="dark"] .installer-platform {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(226, 232, 240, 0.18);
}

:root[data-theme="dark"] .installer-platform:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.105);
}

:root[data-theme="dark"] .installer-platform.selected {
  background: rgba(99, 102, 241, 0.20);
  border-color: rgba(129, 140, 248, 0.72);
}

:root[data-theme="dark"] .installer-logo-wrap {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(226, 232, 240, 0.16);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] .captcha-box {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  border-color: rgba(226, 232, 240, 0.18);
}

:root[data-theme="dark"] input::placeholder {
  color: rgba(226, 232, 240, 0.55);
}

:root[data-theme="dark"] .app-modal-header {
  background: #151a27;
  color: #f8fafc;
  border-bottom-color: rgba(226, 232, 240, 0.12);
}

:root[data-theme="dark"] .app-frame-container,
:root[data-theme="dark"] .modal-iframe-frame,
:root[data-theme="dark"] .app-modal-overlay {
  background: #111521;
}

@media (max-width: 420px) {
  .installer-platform {
    min-height: 66px;
    gap: 10px;
  }

  .installer-logo-wrap {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .installer-logo {
    width: 34px;
    height: 34px;
  }
}

/* === v6.6 UX repair pack: platform selection, login validation, OTP, theme contrast === */
.modal-overlay.active .modal-content,
.modal-overlay:not([hidden]) .modal-content {
  animation: modalLift .28s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes modalLift {
  from {
    opacity: 0;
    transform: translateY(14px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#platform-select-modal .modal-content {
  max-width: 560px;
  border-radius: 28px;
  overflow: hidden;
}

#platform-select-modal .modal-header {
  align-items: center;
}

#platform-select-modal .modal-help {
  text-align: center;
  line-height: 1.9;
}

.installer-container {
  display: grid;
  gap: 12px;
}

.installer-platform {
  position: relative;
  overflow: hidden;
  transition: transform .22s cubic-bezier(.34, 1.56, .64, 1), box-shadow .22s ease, border-color .22s ease, background .22s ease;
}

.installer-platform::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: -80%;
  width: 42%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent);
  transform: skewX(-18deg);
  transition: inset-inline-start .55s ease;
  pointer-events: none;
}

.installer-platform:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(15, 23, 42, .10);
}

.installer-platform:hover:not(:disabled)::after {
  inset-inline-start: 130%;
}

.installer-platform.selected::before {
  content: '✓';
  position: absolute;
  inset-inline-end: 14px;
  inset-block-start: 14px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary, #6366f1);
  color: #fff;
  font-weight: 1000;
  font-size: .8rem;
}

input.input-valid {
  border-color: rgba(16, 185, 129, .72) !important;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, .10);
}

input.input-invalid {
  border-color: rgba(239, 68, 68, .76) !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, .10);
}

#phone-number {
  direction: ltr;
  text-align: left;
  font-weight: 800;
  letter-spacing: .02em;
}

.otp-container {
  gap: 9px;
  align-items: center;
}

.otp-input {
  border: 1.5px solid var(--border);
  background: rgba(248, 250, 252, .82);
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), border-color .18s ease, box-shadow .18s ease, background .18s ease;
  caret-color: var(--primary);
}

.otp-input:focus {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12), 0 10px 24px rgba(15, 23, 42, .08);
}

.otp-container.success .otp-input {
  border-color: rgba(16, 185, 129, .76);
  background: rgba(16, 185, 129, .08);
}

.otp-container.error .otp-input {
  border-color: rgba(239, 68, 68, .78);
  background: rgba(239, 68, 68, .06);
}

:root[data-theme="dark"] .installer-platform::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08), transparent);
}

:root[data-theme="dark"] .otp-input,
:root[data-theme="dark"] #phone-number,
:root[data-theme="dark"] #captcha-input {
  background: rgba(255, 255, 255, .07);
  color: #f8fafc;
  border-color: rgba(226, 232, 240, .18);
}

:root[data-theme="dark"] .otp-input:focus,
:root[data-theme="dark"] #phone-number:focus,
:root[data-theme="dark"] #captcha-input:focus {
  background: rgba(255, 255, 255, .10);
  border-color: #818cf8;
  box-shadow: 0 0 0 4px rgba(129, 140, 248, .16);
}

:root[data-theme="dark"] .otp-container.success .otp-input {
  background: rgba(52, 211, 153, .10);
  border-color: rgba(52, 211, 153, .72);
}

:root[data-theme="dark"] .otp-container.error .otp-input {
  background: rgba(248, 113, 113, .10);
  border-color: rgba(248, 113, 113, .72);
}

:root[data-theme="dark"] .platform-logo,
:root[data-theme="dark"] .installer-logo,
:root[data-theme="dark"] .support-icon {
  filter: none;
}

:root[data-theme="dark"] .initials-logo,
:root[data-theme="dark"] .installer-logo-wrap {
  color: #f8fafc;
}

@media (max-width: 480px) {
  #platform-select-modal .modal-content {
    border-radius: 24px;
  }

  .installer-platform {
    min-height: 70px;
    padding-inline-end: 42px;
  }

  .otp-container {
    gap: 7px;
  }

  .otp-input {
    width: 39px;
    height: 50px;
    font-size: 1.22rem;
    border-radius: 15px;
  }
}

@media (max-width: 360px) {
  .otp-input {
    width: 34px;
    height: 46px;
    font-size: 1.08rem;
  }
}

/* ===== Modal shake — نشان می‌دهد که این modal اجباری است و نمی‌توان آن را بست ===== */
@keyframes modal-shake {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-9px); }
  30%  { transform: translateX(8px); }
  45%  { transform: translateX(-7px); }
  60%  { transform: translateX(6px); }
  75%  { transform: translateX(-4px); }
  90%  { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

.modal-shake {
  animation: modal-shake 0.46s cubic-bezier(.36,.07,.19,.97) both;
}

/* ===== Platform button — حالت در حال بارگذاری بهتر ===== */
/* وقتی auth کامل شده ولی system-status هنوز نرسیده، دکمه‌ها shimmer می‌زنند */
.platform-btn.status-pending {
  opacity: 0.82;
  background: linear-gradient(
    90deg,
    var(--modal-bg) 0%,
    color-mix(in srgb, var(--modal-bg) 80%, var(--primary) 20%) 50%,
    var(--modal-bg) 100%
  );
  background-size: 200% 100%;
  animation: btn-shimmer 1.8s ease-in-out infinite;
}

@keyframes btn-shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* حالت status-pending روی صفحه‌های تاریک */
[data-theme="dark"] .platform-btn.status-pending {
  background: linear-gradient(
    90deg,
    var(--modal-bg) 0%,
    color-mix(in srgb, var(--modal-bg) 70%, var(--primary) 30%) 50%,
    var(--modal-bg) 100%
  );
  background-size: 200% 100%;
  animation: btn-shimmer 1.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {

  .modal-overlay.active .modal-content,
  .modal-overlay:not([hidden]) .modal-content,
  .installer-platform,
  .otp-input,
  .modal-shake,
  .platform-btn.status-pending {
    animation: none !important;
    transition: none !important;
  }
}