:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #17211e;
  --muted: #5d6b66;
  --line: #dde4e1;
  --accent: #0f6b57;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ed;
  --hot: #b4371c;
  --hot-soft: #fbe9e4;
  --warm: #9a6a00;
  --warm-soft: #fbf1d9;
  --cold: #4c5d78;
  --cold-soft: #e9edf4;
  --danger: #a12626;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.75;
}

h1 { font-size: 1.6rem; line-height: 1.4; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: 0 0 1rem; }
[hidden] { display: none !important; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--accent); }

.steps { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 0; padding: 0; counter-reset: step; font-size: .9rem; color: var(--muted); }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 6px; }
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--line); color: var(--muted); font-size: .8rem; font-weight: 600;
}
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active::before { background: var(--accent); color: var(--accent-ink); }
.steps li.done::before { content: "✓"; background: var(--accent-soft); color: var(--accent); }

main { max-width: 860px; margin: 0 auto; padding: 28px 16px 64px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.center { text-align: center; }
.lead { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; }
.error { color: var(--danger); font-weight: 500; }

.facts { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 8px; }
.facts li { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; }

.field { display: grid; gap: 4px; margin-bottom: 18px; max-width: 320px; }
.field span { font-weight: 500; }
input[type="password"] { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.depth { border: 0; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.depth legend { font-weight: 500; padding: 0; margin-bottom: 6px; }
.option, .consent { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.option { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input, .consent input { margin-top: 7px; accent-color: var(--accent); flex: none; }
.consent { margin-bottom: 20px; font-size: .95rem; }

button, .button {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 20px; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; display: inline-block;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:disabled { opacity: .55; cursor: default; }
.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.danger { background: transparent; color: var(--danger); border-color: var(--danger); }

.qr-box { width: 312px; height: 312px; max-width: 100%; margin: 20px auto; padding: 16px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.qr-box img { width: 100%; height: auto; image-rendering: pixelated; }
.howto { width: fit-content; text-align: start; margin: 0 auto 20px; padding-inline-start: 22px; color: var(--muted); }

.spinner { width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 4s; } }

.center-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.warn { color: var(--hot); font-weight: 500; }

.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 0 auto 14px; max-width: 420px; }
.bar div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }

/* Report ---------------------------------------------------------------------------- */
.report-actions { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; }
.report-actions .buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 6px; }
.status { font-weight: 500; }
.status.ok { color: var(--accent); }
.status.bad { color: var(--danger); }

.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; }
.report header { border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 22px; }
.report header p { color: var(--muted); margin: 0; }
.report section { margin-bottom: 28px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.3; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.hot b { color: var(--hot); } .stat.warm b { color: var(--warm); } .stat.cold b { color: var(--cold); }

.customer { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 12px; break-inside: avoid; }
.customer-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 6px; }
.customer-head .phone { color: var(--muted); direction: ltr; unicode-bidi: isolate; font-size: .9rem; }
.rank { color: var(--muted); font-weight: 600; }
.badge { border-radius: 99px; padding: 1px 12px; font-size: .85rem; font-weight: 600; margin-inline-start: auto; }
.badge.hot { background: var(--hot-soft); color: var(--hot); }
.badge.warm { background: var(--warm-soft); color: var(--warm); }
.badge.cold { background: var(--cold-soft); color: var(--cold); }
.badge.do_not_contact { background: #eee; color: #444; }
.meta { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.customer dl { margin: 0; display: grid; gap: 6px; }
.customer dt { font-weight: 600; font-size: .9rem; color: var(--muted); }
.customer dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.chips li { background: var(--accent-soft); border-radius: 8px; padding: 0 10px; font-size: .9rem; }
.chips.risk li { background: var(--hot-soft); }
.draft { background: var(--bg); border-radius: 10px; padding: 10px 14px; white-space: pre-wrap; }

.plain { margin: 0; padding-inline-start: 20px; }
.empty { color: var(--muted); }
.notes { color: var(--muted); font-size: .9rem; }

@media (max-width: 560px) {
  .card, .report { padding: 20px 16px; }
  .steps li { font-size: 0; gap: 0; } /* numbers only on phones */
  .steps li.active { font-size: .9rem; gap: 6px; }
}

@media print {
  @page { size: A4; margin: 16mm 14mm; }
  body { background: #fff; font-size: 11.5pt; }
  .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .report { border: 0; padding: 0; }
  .stat, .customer { border-color: #999; }
  h2 { break-after: avoid; }
}
