/* ===========================================================
   Proofline Mini App — премиальная тёмно-синяя тема
   =========================================================== */

:root {
  --bg: #0b1220;
  --bg-2: #0e1729;
  --surface: #121d33;
  --surface-2: #17233d;
  --surface-3: #1c2a49;
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);
  --text: #eaf0fb;
  --text-dim: #94a1c2;
  --text-faint: #6b7797;
  --accent: #4f86ff;
  --accent-2: #7aa4ff;
  --mint: #2fd6a6;
  --gold: #d8be85;
  --danger: #ff6b6b;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, input, textarea { font-family: inherit; }

button { cursor: pointer; }

::selection { background: rgba(79, 134, 255, 0.35); }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- ambient background ---------- */

.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at top, #0d1730 0%, var(--bg) 55%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  will-change: transform;
}

.orb-a {
  width: 60vw;
  height: 60vw;
  max-width: 420px;
  max-height: 420px;
  top: -18%;
  right: -20%;
  background: radial-gradient(circle, rgba(79, 134, 255, 0.55), transparent 70%);
  animation: drift-a 22s ease-in-out infinite;
}

.orb-b {
  width: 55vw;
  height: 55vw;
  max-width: 380px;
  max-height: 380px;
  bottom: -15%;
  left: -18%;
  background: radial-gradient(circle, rgba(216, 190, 133, 0.28), transparent 70%);
  animation: drift-b 26s ease-in-out infinite;
}

@keyframes drift-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-6%, 8%) scale(1.08); }
}

@keyframes drift-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8%, -6%) scale(1.1); }
}

.grain { display: none; }

/* ---------- layout ---------- */

#app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) 0 calc(24px + env(safe-area-inset-bottom, 0));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 10px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(to bottom, rgba(8, 13, 24, 0.92), rgba(8, 13, 24, 0.75) 80%, transparent);
  backdrop-filter: blur(10px);
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: #0a1120;
  background: linear-gradient(135deg, var(--gold), #f1e2bb);
  box-shadow: 0 6px 18px rgba(216, 190, 133, 0.35);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15.5px; font-weight: 800; letter-spacing: 0.2px; }
.brand-text small { font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.4px; text-transform: uppercase; }

.tabs {
  position: relative;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}

.tab {
  position: relative;
  z-index: 2;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s var(--ease);
}

.tab.active { color: #06101f; }

.tab-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(79, 134, 255, 0.45);
  transition: transform 0.32s var(--ease);
  z-index: 1;
}

.tabs[data-active="faq"] .tab-indicator { transform: translateX(100%); }

.content {
  flex: 1;
  padding: 8px 20px 0;
}

.view { display: none; }
.view.active { display: block; animation: view-in 0.32s var(--ease); }

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- progress ---------- */

.progress {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 4px 18px;
}

.dot {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}

.dot i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--mint));
  transition: width 0.45s var(--ease);
}

.dot.done i { width: 100%; }
.dot.active i { width: 55%; }

/* ---------- step card ---------- */

.card-stage {
  position: relative;
  min-height: 360px;
}

.step-card {
  background: linear-gradient(180deg, var(--surface), var(--surface) 60%, var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px 20px;
  box-shadow: var(--shadow-soft);
  will-change: transform, opacity;
}

.step-card.slide-in-fwd { animation: slideInFwd 0.36s var(--ease); }
.step-card.slide-in-back { animation: slideInBack 0.36s var(--ease); }

@keyframes slideInFwd {
  from { opacity: 0; transform: translateX(28px) scale(0.99); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes slideInBack {
  from { opacity: 0; transform: translateX(-28px) scale(0.99); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.step-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent-2);
  margin: 0 0 6px;
}

.step-title {
  font-size: 19px;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -0.2px;
}

.step-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 18px;
  line-height: 1.45;
}

/* ---------- chips / choice grid ---------- */

.chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  min-height: 44px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
}

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

.chip.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(79, 134, 255, 0.22), rgba(47, 214, 166, 0.12));
  box-shadow: 0 0 0 1px rgba(79, 134, 255, 0.4) inset, 0 8px 20px rgba(79, 134, 255, 0.18);
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  min-height: 44px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
}

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

.option-card .ic {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  border-radius: 9px;
  flex-shrink: 0;
  color: var(--accent-2);
}

.option-card .ic svg { width: 17px; height: 17px; }

.step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--accent-2);
  margin-bottom: 10px;
}

.step-icon svg { width: 18px; height: 18px; }

.option-card .tx { flex: 1; font-size: 14px; font-weight: 700; }

.option-card .ck {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--text-faint);
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.option-card.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(79, 134, 255, 0.18), rgba(47, 214, 166, 0.08));
}

.option-card.selected .ck {
  border-color: var(--accent);
  background: var(--accent);
}

.option-card.selected .ck::after {
  content: '';
  position: absolute;
  left: 5.5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #06101f;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------- inputs ---------- */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.field input[type="text"],
.field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.field input[type="text"]::placeholder,
.field textarea::placeholder { color: var(--text-faint); font-weight: 500; }

.field input[type="text"]:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 134, 255, 0.18);
}

.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

.quick-fill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--accent-2);
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.quick-fill:active { transform: scale(0.97); }
.quick-fill svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ---------- summary ---------- */

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

.summary-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.summary-row .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  min-width: 96px;
}

.summary-row .val {
  flex: 1;
  font-size: 13.5px;
  font-weight: 700;
  text-align: right;
  word-break: break-word;
}

.summary-row .edit {
  border: none;
  background: transparent;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 0 0 6px;
}

.summary-note {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}

/* ---------- success screen ---------- */

.success-wrap { text-align: center; padding: 10px 4px 4px; }

.check-circle {
  width: 84px;
  height: 84px;
  margin: 6px auto 18px;
}

.check-circle svg { width: 100%; height: 100%; }

.check-circle .ring {
  fill: none;
  stroke: url(#pfGradient);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: draw-ring 0.7s var(--ease) forwards;
}

.check-circle .tick {
  fill: none;
  stroke: var(--mint);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: draw-tick 0.4s var(--ease) forwards 0.55s;
}

@keyframes draw-ring { to { stroke-dashoffset: 0; } }
@keyframes draw-tick { to { stroke-dashoffset: 0; } }

.success-wrap h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 4px;
  opacity: 0;
  animation: fade-up 0.4s var(--ease) forwards 0.5s;
}

.case-id {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(216, 190, 133, 0.1);
  border: 1px solid rgba(216, 190, 133, 0.3);
  border-radius: 999px;
  padding: 5px 12px;
  margin: 6px 0 18px;
  opacity: 0;
  animation: fade-up 0.4s var(--ease) forwards 0.62s;
}

.success-steps {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 6px;
}

.success-steps .s-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  color: var(--text-dim);
  opacity: 0;
  transform: translateY(6px);
  animation: fade-up 0.4s var(--ease) forwards;
}

.success-steps .s-row:nth-child(1) { animation-delay: 0.72s; }
.success-steps .s-row:nth-child(2) { animation-delay: 0.82s; }
.success-steps .s-row:nth-child(3) { animation-delay: 0.92s; }

.success-steps .num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--accent-2);
  font-size: 11.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-eta {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-faint);
  opacity: 0;
  animation: fade-up 0.4s var(--ease) forwards 1.02s;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- error banner ---------- */

.error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffb2b2;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  animation: fade-up 0.3s var(--ease);
}

.error-banner svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- fallback buttons (для просмотра вне Telegram) ---------- */

.fallback-actions {
  display: flex;
  gap: 10px;
  padding: 16px 2px 4px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s var(--ease), opacity 0.2s var(--ease), filter 0.2s var(--ease);
}

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

.btn-primary {
  color: #06101f;
  background: linear-gradient(135deg, var(--accent), var(--mint));
  box-shadow: 0 10px 26px rgba(79, 134, 255, 0.3);
}

.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  flex: 0 0 92px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(6, 16, 31, 0.3);
  border-top-color: #06101f;
  animation: spin 0.7s linear infinite;
}

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

/* ---------- FAQ ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 8px 0 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label {
  display: block;
  font-size: 9.5px;
  color: var(--text-faint);
  margin-top: 4px;
  line-height: 1.25;
  font-weight: 600;
}

.faq-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.faq-item {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-q {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  font-size: 13.5px;
  font-weight: 700;
  padding: 15px 16px;
  cursor: pointer;
}

.faq-q .chev {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--accent-2);
  transition: transform 0.3s var(--ease);
}

.faq-item.open .faq-q .chev { transform: rotate(135deg); }

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s var(--ease);
}

.faq-a-inner {
  padding: 0 16px 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
}

.faq-a-inner ul { margin: 6px 0 0; padding-left: 18px; }
.faq-a-inner li { margin-bottom: 4px; }

.faq-disclaimer {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.55;
  text-align: center;
  padding: 4px 8px 10px;
}

/* ---------- responsive tweaks ---------- */

@media (max-width: 360px) {
  .chip-grid { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .orb-a, .orb-b { animation: none; }
  .step-card.slide-in-fwd,
  .step-card.slide-in-back,
  .view.active,
  .success-wrap h2,
  .case-id,
  .success-steps .s-row,
  .success-eta,
  .error-banner { animation: none !important; opacity: 1 !important; transform: none !important; }
  .check-circle .ring,
  .check-circle .tick { animation: none !important; stroke-dashoffset: 0 !important; }
  * { transition-duration: 0.01ms !important; }
}
