:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-soft: #ccfbf1;
  --bg: #f3f9f8;
  --surface: #ffffff;
  --glass: rgba(255, 255, 255, 0.76);
  --text: #16302c;
  --muted: #5f7570;
  --line: #dcebe8;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --info-soft: #e0f2fe;
  --info: #0369a1;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 30px rgba(13, 148, 136, 0.10);
  --shadow-sm: 0 2px 10px rgba(22, 48, 44, 0.07);
  --font: "Vazirmatn", Tahoma, "IranSans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 90% -10%, #d7f4ef 0%, transparent 60%),
    radial-gradient(900px 400px at -10% 20%, #e6f7ff 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.8;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

a { color: var(--primary-dark); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.page {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
  animation: page-in 0.28s ease both;
}

.page.no-nav { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.boot-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 100vh;
}
.boot-logo {
  width: 64px; height: 64px; border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 30px; box-shadow: var(--shadow);
  animation: pulse 1.4s ease-in-out infinite;
}
.boot-text { color: var(--muted); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.topbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; flex: 1; }
.topbar .sub { color: var(--muted); font-size: 12.5px; font-weight: 400; }

.back-btn {
  border: 1px solid var(--line); background: var(--glass);
  width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text); font-size: 17px;
  backdrop-filter: blur(8px);
}
.back-btn:active { transform: scale(0.94); }

.card {
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 8px; font-size: 16.5px; }
.card .card-sub { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

.hero {
  background: linear-gradient(135deg, var(--primary-dark), #0d9488 55%, #14b8a6);
  color: #fff;
  border-radius: 24px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: auto -30px -50px auto;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}
.hero h1 { margin: 0 0 6px; font-size: 21px; }
.hero p { margin: 0 0 16px; opacity: 0.92; font-size: 13.5px; }
.hero .hero-badge {
  display: inline-flex; gap: 6px; align-items: center;
  background: rgba(255,255,255,0.18); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; margin-bottom: 12px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 14px; padding: 13px 20px;
  font-weight: 700; cursor: pointer; font-size: 15px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
  text-align: center;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary-dark); color: #fff; box-shadow: 0 6px 18px rgba(15, 118, 110, 0.35); }
.btn-white { background: #fff; color: var(--primary-dark); box-shadow: 0 6px 18px rgba(0,0,0,0.15); }
.btn-outline { background: var(--surface); color: var(--primary-dark); border: 1.5px solid var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 11px; }
.btn-lg { padding: 16px 22px; font-size: 16px; border-radius: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.quick-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid rgba(255,255,255,0.85);
  border-radius: var(--radius); padding: 18px 10px;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
  color: var(--text);
}
.quick-card:active { transform: scale(0.96); }
.quick-card .qc-icon {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--primary-soft); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.quick-card .qc-label { font-size: 13px; font-weight: 700; }

.type-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 15px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.type-card:active { transform: scale(0.98); }
.type-card.selected { border-color: var(--primary); background: #f0fdfa; }
.type-card .t-icon {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: var(--primary-soft); display: flex; align-items: center; justify-content: center;
  font-size: 21px;
}
.type-card .t-title { font-weight: 700; font-size: 15px; }
.type-card .t-desc { color: var(--muted); font-size: 12.5px; line-height: 1.6; }

.notice {
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 13px;
  line-height: 1.9;
  display: flex; gap: 9px; align-items: flex-start;
  margin-bottom: 14px;
}
.notice .n-icon { flex: none; font-size: 16px; line-height: 1.7; }
.notice-info { background: var(--info-soft); color: var(--info); border: 1px solid #bae6fd; }
.notice-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #fde68a; }
.notice-danger { background: var(--danger-soft); color: #991b1b; border: 1px solid #fecaca; }
.notice-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #bbf7d0; }

.guide-list { margin: 0; padding: 0; list-style: none; }
.guide-list li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.guide-list li:last-child { border-bottom: none; }
.guide-list .g-ok { color: var(--primary); font-weight: 700; flex: none; }

.capture-box {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  padding: 26px 16px;
  text-align: center;
  margin-bottom: 14px;
}
.capture-box .cb-icon { font-size: 40px; }
.capture-box p { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }

.preview-card { text-align: center; }
.preview-img-wrap {
  border-radius: var(--radius); overflow: hidden;
  background: #0f172a; margin-bottom: 14px;
  max-height: 46vh; display: flex; align-items: center; justify-content: center;
}
.preview-img-wrap img { max-width: 100%; max-height: 46vh; object-fit: contain; display: block; }
.preview-actions { display: grid; gap: 10px; }

.hidden-input { display: none; }

.bottom-nav {
  position: fixed; bottom: 0; right: 0; left: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 11.5px; font-weight: 700;
  padding: 4px 12px; border-radius: 12px; min-width: 64px;
}
.bottom-nav a .bn-icon { font-size: 19px; }
.bottom-nav a.active { color: var(--primary-dark); background: var(--primary-soft); }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  z-index: 60; display: flex; align-items: flex-end;
  animation: fade-in 0.2s ease both;
}
.sheet {
  width: 100%; max-width: 640px; margin: 0 auto;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  max-height: 86vh; overflow-y: auto;
}
.sheet .sheet-handle {
  width: 44px; height: 5px; background: var(--line);
  border-radius: 99px; margin: 6px auto 14px;
}
.sheet h3 { margin: 0 0 10px; font-size: 17px; }
.sheet .sheet-actions { display: grid; gap: 10px; margin-top: 16px; }

@keyframes sheet-up { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  z-index: 70; display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade-in 0.18s ease both;
}
.modal {
  background: var(--surface); border-radius: 20px;
  width: 100%; max-width: 420px; padding: 20px;
  animation: modal-in 0.22s ease both;
}
.modal h3 { margin: 0 0 8px; font-size: 16.5px; }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.modal .modal-actions { display: flex; gap: 10px; }
.modal .modal-actions .btn { flex: 1; }

@keyframes modal-in { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }

.loading-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(243, 249, 248, 0.94);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
  animation: fade-in 0.2s ease both;
}
.spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 4px solid var(--primary-soft);
  border-top-color: var(--primary-dark);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-steps { width: 100%; max-width: 340px; display: grid; gap: 10px; }
.loading-step {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 14px;
  font-size: 13.5px; color: var(--muted);
  opacity: 0.5; transform: translateY(6px);
  transition: all 0.3s ease;
}
.loading-step .ls-dot {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--line); position: relative;
}
.loading-step.active { opacity: 1; transform: none; color: var(--text); border-color: var(--primary); }
.loading-step.active .ls-dot { border-color: var(--primary); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.loading-step.done { opacity: 1; transform: none; color: var(--ok); }
.loading-step.done .ls-dot { border-color: var(--ok); background: var(--ok); }
.loading-step.done .ls-dot::after {
  content: "✓"; color: #fff; font-size: 11px;
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.loading-title { font-weight: 700; font-size: 16px; text-align: center; }
.loading-hint { color: var(--muted); font-size: 13px; text-align: center; }

.toast-root {
  position: fixed; top: calc(14px + env(safe-area-inset-top));
  right: 14px; left: 14px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #16302c; color: #fff;
  border-radius: 14px; padding: 11px 18px;
  font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: toast-in 0.25s ease both;
  max-width: 480px; text-align: center;
  pointer-events: auto;
}
.toast.success { background: var(--ok); }
.toast.error { background: #b91c1c; }
.toast.warn { background: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

.offline-bar {
  position: fixed; bottom: calc(74px + env(safe-area-inset-bottom));
  right: 14px; left: 14px; z-index: 50;
  background: #1e293b; color: #fff; border-radius: 14px;
  padding: 10px 16px; font-size: 13px; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.install-bar {
  position: fixed; top: calc(12px + env(safe-area-inset-top));
  right: 14px; left: 14px; z-index: 55;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 700;
}
.install-bar span { flex: 1; }

.skeleton {
  background: linear-gradient(90deg, #e7f1ef 25%, #f3faf8 50%, #e7f1ef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 12px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.list-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--glass); border: 1px solid rgba(255,255,255,0.85);
  border-radius: var(--radius); padding: 13px;
  margin-bottom: 10px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease;
  color: var(--text);
}
.list-item:active { transform: scale(0.985); }
.list-item .li-thumb {
  width: 56px; height: 56px; border-radius: 14px; flex: none;
  object-fit: cover; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; overflow: hidden;
}
.list-item .li-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 700; font-size: 14.5px; }
.list-item .li-meta { color: var(--muted); font-size: 12px; }
.list-item .li-arrow { color: var(--muted); font-size: 16px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 11px;
  font-size: 11.5px; font-weight: 700;
}
.badge-info { background: var(--info-soft); color: var(--info); }
.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: #991b1b; }
.badge-muted { background: #eef2f1; color: var(--muted); }

.result-section { margin-bottom: 16px; }
.result-section h3 {
  font-size: 14.5px; margin: 0 0 8px;
  color: var(--primary-dark); display: flex; align-items: center; gap: 7px;
}
.result-summary {
  font-size: 15.5px; line-height: 2; background: #f0fdfa;
  border: 1px solid #99f6e4; border-radius: var(--radius-sm);
  padding: 14px;
}

.finding-item, .condition-item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 9px;
}
.finding-item .f-title, .condition-item .c-title { font-weight: 700; font-size: 14px; }
.finding-item .f-desc, .condition-item .c-reason { color: var(--muted); font-size: 13px; margin-top: 3px; }
.condition-item .c-likelihood { margin-top: 7px; }

.red-flag-box {
  background: linear-gradient(135deg, #fff1f2, #ffe4e6);
  border: 1.5px solid #fda4af; border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.red-flag-box h3 { margin: 0 0 6px; color: #9f1239; font-size: 15.5px; }
.red-flag-box ul { margin: 6px 0 0; padding-right: 18px; color: #881337; font-size: 13.5px; }
.red-flag-box li { margin-bottom: 5px; }

.question-card {
  background: var(--glass); border: 1px solid rgba(255,255,255,0.85);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.question-card .q-text { font-weight: 700; font-size: 14.5px; margin-bottom: 12px; }
.question-card .q-idx { color: var(--primary-dark); font-size: 12px; }

.choice-list { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 13px; padding: 11px 14px;
  cursor: pointer; font-size: 14px;
  transition: border-color 0.12s, background 0.12s;
}
.choice.selected { border-color: var(--primary); background: #f0fdfa; }
.choice input { accent-color: var(--primary-dark); width: 17px; height: 17px; }

.bool-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bool-btn {
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 13px; padding: 12px; font-weight: 700;
  cursor: pointer; font-size: 14.5px; color: var(--text);
}
.bool-btn.selected { border-color: var(--primary); background: #f0fdfa; color: var(--primary-dark); }

textarea.field, input.field, select.field {
  width: 100%; border: 1.5px solid var(--line);
  background: var(--surface); border-radius: 13px;
  padding: 12px 14px; outline: none; color: var(--text);
  transition: border-color 0.15s;
  font-size: 14.5px;
}
textarea.field { min-height: 96px; resize: vertical; }
.field:focus { border-color: var(--primary); }

.field-label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; }
.field-group { margin-bottom: 14px; }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 5px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.tab {
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 7px 16px; font-size: 13.5px;
  font-weight: 700; cursor: pointer; color: var(--muted); white-space: nowrap;
}
.tab.active { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.empty-state {
  text-align: center; padding: 44px 20px; color: var(--muted);
}
.empty-state .es-icon { font-size: 44px; margin-bottom: 10px; }
.empty-state .es-title { font-weight: 700; color: var(--text); font-size: 15.5px; margin-bottom: 4px; }

.stepper { display: flex; gap: 8px; margin-bottom: 16px; }
.stepper .step {
  flex: 1; height: 5px; border-radius: 99px; background: var(--line);
}
.stepper .step.active { background: var(--primary); }

.timeline { position: relative; padding-right: 18px; }
.timeline::before {
  content: ""; position: absolute; right: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.timeline-item { position: relative; margin-bottom: 14px; }
.timeline-item::before {
  content: ""; position: absolute; right: -18px; top: 16px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 2.5px solid var(--primary-soft);
}

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12.5px; }
.meta-grid .meta-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; }
.meta-grid .meta-item b { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }

.divider { height: 1px; background: var(--line); margin: 14px 0; }

.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; }
.mb-0 { margin-bottom: 0; }

.noscript-box {
  max-width: 480px; margin: 40px auto; background: var(--warn-soft);
  color: var(--warn); padding: 20px; border-radius: 16px; text-align: center;
}

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 6px 0;
}
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--line);
  border-radius: 99px; cursor: pointer; transition: background 0.2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; top: 3px; right: 3px;
  transition: transform 0.2s; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(-20px); }

@media (min-width: 720px) {
  body { font-size: 16px; }
  .page { max-width: 720px; padding-top: 28px; }
  .grid-3 { gap: 14px; }
  .bottom-nav { border-radius: 20px; max-width: 560px; margin: 0 auto 14px; bottom: 14px; right: 0; left: 0; border: 1px solid var(--line); }
}
