:root {
  --bg: #F6F5F0;
  --surface: #FFFFFF;
  --surface-2: #FBFAF6;
  --ink: #14231F;
  --muted: #5E6B67;
  --line: #E4E1D8;
  --brand: #0F6B5C;
  --brand-2: #0A5045;
  --brand-soft: #E2EFEB;
  --accent: #E7A33E;
  --accent-soft: #FBF0DC;
  --danger: #C2493B;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20,35,31,.04), 0 8px 24px rgba(20,35,31,.06);
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(246,245,240,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-name { font-weight: 700; font-size: 21px; }
.brand-name .en { font-weight: 500; color: var(--brand); margin-inline-start: 4px; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lang-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 14px; font-weight: 600; font-size: 14px; color: var(--brand);
}
.lang-btn:hover { border-color: var(--brand); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a {
  text-decoration: none; padding: 8px 14px; border-radius: 999px;
  color: var(--muted); font-weight: 500; font-size: 15px;
}
nav a:hover { color: var(--ink); background: var(--surface); }
nav a.active { color: var(--brand); background: var(--brand-soft); }

main { max-width: 1180px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 48px) 64px; min-height: 70vh; }

footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  padding: 20px clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; text-decoration: none; transition: .15s ease;
}
.btn.lg { padding: 14px 24px; font-size: 17px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; }
.link:hover { text-decoration: underline; }

.eyebrow { display: inline-block; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--brand); }
.muted { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h3 { font-size: 18px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--brand)) 12%, white);
  color: var(--c, var(--brand));
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; padding: 24px 0 48px; }
.hero h1 { font-size: clamp(36px, 5vw, 56px); margin: 14px 0 18px; font-weight: 700; }
.hero h1 em { font-style: normal; color: var(--brand); }
.lead { font-size: 19px; color: var(--muted); max-width: 560px; margin: 0 0 28px; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.trust { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 24px; color: var(--muted); font-size: 14px; }
.trust span::before { content: '✓ '; color: var(--brand); font-weight: 700; }

.hero-card { position: relative; }
.hero-card .card { padding: 22px; }
.hero-card .float {
  position: absolute; inset-inline-start: -28px; bottom: -22px;
  background: var(--accent-soft); border: 1px solid #F1DDB5; border-radius: 14px;
  padding: 10px 14px; font-size: 14px; box-shadow: var(--shadow);
}
.mini-row { display: grid; grid-template-columns: 1fr 120px 42px; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.mini-row b { font-weight: 600; }
.mini-bar { height: 8px; background: var(--brand-soft); border-radius: 99px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

.section-title { font-size: 28px; margin: 40px 0 6px; }
.section-sub { color: var(--muted); margin: 0 0 22px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.step .num {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; margin-bottom: 14px;
}
.step h3 { margin-bottom: 6px; }
.step p { margin: 0; color: var(--muted); }

.audiences { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.aud { border-top: 4px solid var(--c); }
.aud ul { margin: 10px 0 0; padding-inline-start: 18px; color: var(--muted); }
.aud li { margin: 4px 0; }

/* ---------- Start (profile) ---------- */
.start { display: grid; grid-template-columns: .9fr 1.1fr; gap: 40px; align-items: start; }
.start h1 { font-size: 36px; margin: 10px 0 12px; }
.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.form input, .form select {
  font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink);
}
.form input:focus, .form select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; }
.checklist { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 12px; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; }
.checklist .ic { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; }

/* ---------- Assessment ---------- */
.assess { max-width: 780px; margin: 0 auto; }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.st { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.st span {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); background: var(--surface); font-size: 12px;
}
.st.cur { color: var(--ink); }
.st.cur span { border-color: var(--brand); color: var(--brand); }
.st.done span { background: var(--brand); border-color: var(--brand); color: #fff; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); transition: width .3s ease; }
.meta { display: flex; justify-content: space-between; margin: 10px 0 20px; font-size: 14px; color: var(--muted); }

.qcard { padding: clamp(22px, 4vw, 40px); animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.qcard .blurb { color: var(--muted); margin: 14px 0 6px; font-size: 15px; }
.qcard h2 { font-size: clamp(22px, 3vw, 28px); font-weight: 600; margin-bottom: 26px; }

.likert { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.lk {
  display: grid; justify-items: center; gap: 10px; padding: 16px 6px;
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 14px;
  font-size: 13px; font-weight: 500; color: var(--muted); transition: .12s;
}
.lk .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: #fff; }
.lk:nth-child(1) .dot { width: 24px; height: 24px; }
.lk:nth-child(2) .dot { width: 20px; height: 20px; }
.lk:nth-child(4) .dot { width: 20px; height: 20px; }
.lk:nth-child(5) .dot { width: 24px; height: 24px; }
.lk:hover { border-color: var(--brand); color: var(--ink); }
.lk.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.lk.on .dot { background: var(--brand); border-color: var(--brand); box-shadow: inset 0 0 0 3px #fff; }

.choices { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px; text-align: start;
  padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2);
  font-size: 16px; transition: .12s;
}
.opt .key {
  flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line); font-weight: 700; font-size: 13px; color: var(--muted);
}
.opt:hover { border-color: var(--brand); }
.opt.on { border-color: var(--brand); background: var(--brand-soft); }
.opt.on .key { background: var(--brand); color: #fff; border-color: var(--brand); }

.hint { color: var(--muted); margin: -12px 0 16px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface-2);
  font-weight: 500; font-size: 15px; transition: .12s;
}
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.static { cursor: default; padding: 6px 12px; font-size: 14px; }

.qnav { display: flex; justify-content: space-between; margin-top: 30px; }
.kbd-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; }

.loader { text-align: center; padding: 80px 0; }
.loader .spin {
  width: 56px; height: 56px; margin: 0 auto 20px; border-radius: 50%;
  border: 5px solid var(--brand-soft); border-top-color: var(--brand); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Results ---------- */
.res-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.res-head h1 { font-size: clamp(28px, 4vw, 40px); margin: 8px 0 14px; }
.code-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.clarity { font-size: 14px; color: var(--muted); margin-inline-start: 6px; }
.res-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.top-match { border-top: 5px solid var(--c); }
.tm-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 16px 0 6px; }
.tm-row h2 { font-size: 30px; margin-top: 4px; }
.tm-row p { margin: 0; }
.ring {
  flex: none; width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center; align-content: center;
  background: conic-gradient(var(--c, var(--brand)) calc(var(--p) * 1%), var(--brand-soft) 0);
  position: relative;
}
.ring::before { content: ''; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.ring b, .ring small { position: relative; }
.ring b { font-size: 26px; line-height: 1; }
.ring small { color: var(--muted); font-size: 12px; }
.top-match h4 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 10px; }
.why { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.why li { display: flex; gap: 10px; }
.why li::before { content: '✓'; color: var(--brand); font-weight: 700; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills span { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.tm-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.tm-foot div { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; }
.tm-foot small { display: block; color: var(--muted); font-size: 12px; }
.callout { margin-top: 14px; background: var(--accent-soft); border: 1px solid #F1DDB5; border-radius: 12px; padding: 10px 14px; font-size: 14px; }

.stack { display: flex; height: 18px; border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.stack i { display: block; height: 100%; }
.legend { list-style: none; padding: 0; margin: 0 0 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-inline-start: auto; }
.radar-wrap { display: grid; grid-template-columns: 1fr; justify-items: center; }
.radar text { font-family: var(--font); font-size: 12px; fill: var(--muted); }
.radar text.v { font-weight: 700; fill: var(--ink); }

.ranked { list-style: none; padding: 0; margin: 0; }
.ranked li {
  display: grid; grid-template-columns: 28px minmax(0, 1.3fr) minmax(0, 1fr) 48px; gap: 14px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.ranked li:last-child { border-bottom: 0; }
.ranked li.more { display: none; }
.ranked.all li.more { display: grid; }
.rk { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.rn b { display: block; font-weight: 600; }
.rn small { color: var(--muted); font-size: 13px; }
.rb { height: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.rb i { display: block; height: 100%; border-radius: 99px; }
.rp { font-weight: 700; text-align: end; }

.skill { display: grid; grid-template-columns: 90px 1fr 40px; gap: 12px; align-items: center; margin: 12px 0; font-size: 15px; }
.skill .rb i { background: var(--accent); }
.next ol { margin: 0; padding-inline-start: 20px; display: grid; gap: 10px; }
.next li::marker { color: var(--brand); font-weight: 700; }
.disclaimer { color: var(--muted); font-size: 13px; text-align: center; margin-top: 28px; }
.empty { max-width: 520px; margin: 40px auto; text-align: center; }
.empty h2 { margin-bottom: 8px; }
.empty .cta-row { justify-content: center; margin-top: 20px; }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.dash-head h1 { font-size: 34px; margin-top: 8px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg button.on { background: var(--brand); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { padding: 20px; }
.kpi small { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi b { display: block; font-size: 30px; margin: 4px 0 2px; letter-spacing: -.02em; }
.kpi .delta { font-size: 13px; color: var(--brand); font-weight: 600; }
.hbar { display: grid; grid-template-columns: 210px 1fr 48px; gap: 12px; align-items: center; margin: 12px 0; font-size: 14px; }
.hbar .rb { height: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 10px; border-bottom: 1px solid var(--line); }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
.status { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status.ok { background: var(--brand-soft); color: var(--brand); }
.status.warn { background: var(--accent-soft); color: #9A6511; }
.status.alert { background: #FBE6E2; color: var(--danger); }
.insights { display: grid; gap: 12px; }
.insight { display: flex; gap: 12px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.insight .ic { font-size: 20px; }
.insight p { margin: 0; font-size: 14px; }
.insight b { display: block; font-size: 15px; margin-bottom: 2px; }
.table-scroll { overflow-x: auto; }
.sample { font-size: 12px; font-weight: 600; color: #9A6511; background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s ease; z-index: 50; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero, .start, .grid-2 { grid-template-columns: 1fr; }
  .steps, .audiences { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .hero-card .float { inset-inline-start: 12px; }
  .hbar { grid-template-columns: 140px 1fr 44px; }
}
@media (max-width: 620px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  nav a { padding: 6px 10px; font-size: 14px; }
  .likert { grid-template-columns: 1fr; }
  .lk { grid-template-columns: auto 1fr; justify-items: start; align-items: center; padding: 12px 14px; font-size: 15px; }
  .stepper { grid-template-columns: repeat(4, auto); justify-content: space-between; }
  .st { font-size: 0; gap: 0; }
  .st span { font-size: 12px; }
  .form .row, .legend, .tm-foot { grid-template-columns: 1fr; }
  .ranked li { grid-template-columns: 28px 1fr 44px; }
  .ranked li .rb { grid-column: 2 / 4; grid-row: 2; }
  .mini-row { grid-template-columns: 1fr 70px 38px; }
}

/* ---------- Arabic / RTL ---------- */
/* Letter-spacing breaks Arabic letter joining, and uppercase has no meaning in Arabic. */
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4,
[dir="rtl"] .eyebrow, [dir="rtl"] th, [dir="rtl"] .kpi b { letter-spacing: 0; text-transform: none; }
[dir="rtl"] body { line-height: 1.7; }
[dir="rtl"] .hero h1 { line-height: 1.3; }
[dir="rtl"] .top-match h4 { font-size: 15px; }
[dir="rtl"] .eyebrow { font-size: 14px; }

@media print {
  .topbar, footer, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .ranked li.more { display: grid; }
}
