:root {
  --ink: #15243a;
  --muted: #64748b;
  --paper: #ffffff;
  --wash: #f3f7fb;
  --line: #dce6f0;
  --brand: #0f766e;
  --brand-dark: #0b4f4a;
  --accent: #f59e0b;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(20, 39, 64, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; max-width: 100%; }
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(15,118,110,.10), transparent 24rem),
    var(--wash);
  font-family: Tahoma, Arial, sans-serif;
  line-height: 1.75;
}

.hero {
  color: #fff;
  background: linear-gradient(125deg, #10243e 0%, #0f766e 78%, #15847a 100%);
  border-bottom: 5px solid var(--accent);
}
.hero__inner { width: min(1060px, calc(100% - 32px)); margin: auto; padding: 46px 0 40px; }
.eyebrow { color: #fde68a; font-weight: 700; letter-spacing: .04em; }
.hero h1 { margin: 4px 0 0; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.2; }
.hero p { margin: 4px 0 18px; font-size: 1.15rem; color: #d6f4ef; }
.meta { display: flex; flex-wrap: wrap; gap: 10px; }
.meta span { padding: 5px 13px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; background: rgba(255,255,255,.08); }

.container { width: min(1060px, calc(100% - 28px)); margin: 28px auto 60px; }
.intro-card, .progress-shell, .form-step, .success-card, .alert {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.intro-card { padding: 22px 26px; margin-bottom: 18px; }
.intro-card h2 { margin: 0 0 4px; }
.intro-card p { margin: 4px 0; }
.privacy { color: var(--brand-dark); font-weight: 700; }
.muted { color: var(--muted); }

.alert { padding: 16px 22px; margin-bottom: 18px; }
.alert.error { border-right: 5px solid var(--danger); color: #7a271a; background: #fff8f6; }
.alert ul { margin: 6px 0 0; }

.progress-shell { position: sticky; top: 10px; z-index: 20; padding: 15px 18px 11px; margin-bottom: 18px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: .9rem; }
.progress-track { height: 8px; background: #e7edf4; border-radius: 999px; overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--brand)); border-radius: inherit; transition: width .3s ease; }
.steps { display: grid; grid-template-columns: repeat(7, 1fr); list-style: none; margin: 10px 0 0; padding: 0; gap: 4px; color: var(--muted); font-size: .72rem; text-align: center; }
.steps li.active { color: var(--brand); font-weight: 700; }
.steps li.done { color: var(--ink); }

.form-step { display: none; padding: clamp(18px, 4vw, 38px); }
.form-step.active { display: block; animation: reveal .25s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }
.section-heading { display: flex; align-items: center; gap: 15px; padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.section-heading > span { display: grid; place-items: center; width: 54px; height: 54px; flex: 0 0 54px; border-radius: 16px; color: #fff; background: var(--brand); font-size: 1.15rem; font-weight: 700; }
.section-heading h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.8rem); line-height: 1.3; }
.section-heading p { margin: 2px 0 0; color: var(--muted); }

.student-grid, .inline-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.student-grid label, .inline-grid label, .rank-grid label { display: grid; gap: 6px; font-weight: 700; }
.student-grid label:last-child { grid-column: 1 / -1; max-width: 50%; }
input, textarea, select {
  width: 100%; border: 1px solid #bdcad8; border-radius: 11px; padding: 11px 13px; color: var(--ink); background: #fff; font: inherit; font-weight: 400; transition: border .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 92px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(15,118,110,.13); }
input:user-invalid, textarea:user-invalid, select:user-invalid { border-color: var(--danger); }

.question { border: 0; border-bottom: 1px solid var(--line); padding: 4px 0 25px; margin: 0 0 24px; min-width: 0; }
.question:last-child { border-bottom: 0; }
.question legend { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 0; margin-bottom: 14px; font-size: 1.06rem; font-weight: 700; line-height: 1.65; }
.question legend > span:nth-child(2) { flex: 1; }
.question legend small { white-space: nowrap; color: var(--brand); background: #e7f7f4; padding: 2px 9px; border-radius: 999px; font-size: .75rem; }
.number { display: inline-grid; place-items: center; width: 31px; height: 31px; flex: 0 0 31px; border-radius: 9px; background: #eaf1f7; color: #254361; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.option { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 11px; cursor: pointer; background: #fbfdff; transition: .15s; }
.option:hover { border-color: #7ebbb4; background: #f4fbfa; }
.option:has(input:checked) { border-color: var(--brand); background: #eaf8f5; box-shadow: inset 0 0 0 1px var(--brand); }
.option input { width: auto; accent-color: var(--brand); }
.choice { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; color: var(--brand-dark); background: #dff3ef; font-weight: 700; }
.rank-grid { display: grid; gap: 10px; }
.rank-grid label { grid-template-columns: 1fr 145px; align-items: center; padding: 8px 12px; border-radius: 11px; background: #f7fafc; }
.inline-grid.three { grid-template-columns: repeat(3, 1fr); }

.code-sample { margin: 0 0 25px; padding: 20px; border: 1px solid #263d55; border-radius: 14px; background: #132238; color: #b8f6df; overflow-x: auto; line-height: 2; text-align: left; }
.code-sample code { font-family: Consolas, monospace; }
.review-box { padding: 22px; border: 1px solid #b9ddd8; border-radius: 14px; background: #f2fbf9; }
.review-box h3 { margin-top: 0; }
.confirm { display: flex; gap: 10px; align-items: flex-start; padding-top: 12px; font-weight: 700; }
.confirm input { width: 20px; height: 20px; accent-color: var(--brand); }
.submit-note { margin-top: 16px; color: var(--muted); }

.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.button { border: 0; border-radius: 11px; padding: 12px 24px; color: #fff; background: var(--brand); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .15s, background .15s; }
.button:hover { background: var(--brand-dark); transform: translateY(-1px); }
.button.secondary { color: var(--ink); background: #e5edf5; }
.button.submit { background: #c77700; }
.save-status { margin-inline-start: auto; color: var(--muted); font-size: .82rem; }
.honeypot {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.success-card { max-width: 700px; margin: 60px auto; padding: 45px 28px; text-align: center; }
.success-icon { display: grid; place-items: center; width: 74px; height: 74px; margin: 0 auto 14px; border-radius: 50%; color: #fff; background: var(--brand); font-size: 2.2rem; }
.success-card h2 { margin: 0 0 8px; }
.success-card code { display: inline-block; direction: ltr; margin: 5px 0 12px; padding: 7px 12px; border-radius: 8px; background: #edf2f7; }
.success-card .button { display: inline-block; margin-top: 12px; }
footer { padding: 25px; text-align: center; color: var(--muted); }

/* هوية Project Metric */
.hero__inner { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr); align-items: center; gap: clamp(24px, 5vw, 70px); }
.brand-area { display: flex; align-items: center; justify-content: center; gap: 16px; min-width: 0; }
.brand-logo { display: block; flex: 0 1 190px; min-width: 0; }
.brand-logo img { display: block; width: 100%; height: auto; max-height: 82px; object-fit: contain; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { width: min(190px, 48%); height: auto; max-height: 82px; object-fit: contain; }
.brand > span { display: grid; line-height: 1.35; }
.brand strong { font-size: 1.15rem; }
.brand small { color: #d6f4ef; font-size: .78rem; }
.hero-copy { min-width: 0; }
.intro-title { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.intro-title a { color: var(--brand); font-weight: 700; }
.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  padding: 7px 14px 7px 8px;
  border: 1px solid #f7a600;
  border-radius: 999px;
  color: #fff;
  background: #f59e0b;
  font-weight: 700;
  text-decoration: none;
  transition: background .15s, transform .15s;
}
.language-switch span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #8a4b00; background: #fff; font-size: .78rem; }
.language-switch:hover { color: #fff; background: #d97706; border-color: #d97706; transform: translateY(-1px); }
[dir="ltr"] .alert.error { border-right: 1px solid var(--line); border-left: 5px solid var(--danger); }
[dir="ltr"] .option, [dir="ltr"] th, [dir="ltr"] td { text-align: left; }
[dir="ltr"] .site-footer { text-align: left; }
.site-footer { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-inline: max(24px, calc((100vw - 1060px) / 2)); color: #d8e4ee; background: #10243e; text-align: right; }
.site-footer > p { margin: 0; text-align: left; }
.footer-brand { display: flex; align-items: center; gap: 14px; }
.footer-brand img { width: 120px; height: auto; max-height: 54px; object-fit: contain; padding: 5px; border-radius: 8px; background: #fff; }
.footer-brand div { display: grid; gap: 3px; }
.footer-brand a { color: #b9efe7; }

/* صفحة النتيجة */
.result-header { padding: 28px 0; color: #fff; background: linear-gradient(125deg, #10243e, #0f766e); border-bottom: 5px solid var(--accent); }
.result-header > div { display: grid; grid-template-columns: minmax(230px, .7fr) minmax(0, 1.3fr); align-items: center; gap: 36px; width: min(900px, calc(100% - 28px)); margin: auto; }
.result-brand img { max-height: 70px; }
.result-header h1 { margin: 5px 0 0; font-size: clamp(1.7rem, 4vw, 2.6rem); }
.result-header .eyebrow { display: block; }
.back-link { display: inline-block; margin-bottom: 12px; color: #d6f4ef; text-decoration: none; }
.result-container { width: min(900px, calc(100% - 28px)); margin: 26px auto 55px; }
.lookup-card, .student-result, .result-help { border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.lookup-card { display: grid; grid-template-columns: .8fr 1.2fr; align-items: end; gap: 30px; padding: 24px; }
.lookup-card h2, .lookup-card p { margin: 0; }
.lookup-card p { color: var(--muted); }
.lookup-form label { display: block; margin-bottom: 6px; font-weight: 700; }
.lookup-form > div { display: flex; gap: 8px; }
.lookup-form input { text-align: left; font-family: Consolas, monospace; }
.lookup-form button { white-space: nowrap; }
.result-alert { margin-top: 18px; }
.student-result { margin-top: 18px; padding: clamp(20px, 4vw, 34px); }
.print-brand { display: none; }
.result-title-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.result-title-row h2 { margin: 9px 0 0; font-size: clamp(1.5rem, 4vw, 2rem); }
.result-title-row p { margin: 2px 0 0; color: var(--muted); }
.status-pill { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.status-pill.reviewed { color: #075b51; background: #ddf7f2; }
.status-pill.pending-review { color: #8a4b00; background: #fff1ca; }
.final-score { display: grid; place-items: center; min-width: 120px; min-height: 110px; padding: 12px; border-radius: 18px; color: #fff; background: var(--brand); text-align: center; }
.final-score.preliminary { color: #744100; background: #ffe6a5; }
.final-score strong { font-size: 2.2rem; line-height: 1; }
.final-score span { font-size: .85rem; }
.score-progress { height: 12px; margin: 24px 0 15px; border-radius: 999px; overflow: hidden; background: #e4ebf2; }
.score-progress div { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--brand)); }
.score-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.score-breakdown article { display: grid; gap: 4px; padding: 15px; border-radius: 12px; background: #f4f7fa; }
.score-breakdown article span { color: var(--muted); font-size: .85rem; }
.score-breakdown article strong { font-size: 1.1rem; }
.score-breakdown article.total { color: #fff; background: #17304d; }
.score-breakdown article.total span { color: #cdd9e5; }
.pending-message { margin-top: 22px; padding: 17px 19px; border-right: 5px solid var(--accent); border-radius: 10px; background: #fff8e8; }
.pending-message p { margin: 4px 0 0; }
.result-details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 25px; margin: 25px 0 0; }
.result-details > div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.result-details dt { color: var(--muted); }
.result-details dd { margin: 0; font-weight: 700; }
.reference-row { grid-column: 1 / -1; }
.reference-row dd { overflow-wrap: anywhere; }
.teacher-note { margin-top: 24px; padding: 18px; border: 1px solid #b9ddd8; border-radius: 13px; background: #f2fbf9; }
.teacher-note h3, .teacher-note p { margin: 0; }
.teacher-note p { margin-top: 5px; }
.print-signature { display: none; }
.print-footer { display: none; }
.result-actions { display: flex; gap: 10px; margin-top: 16px; }
.print-button { background: #c77700; }
.result-help { display: flex; align-items: center; gap: 18px; margin-top: 18px; padding: 22px; }
.result-help h2, .result-help p { margin: 0; }
.result-help p { color: var(--muted); }
.reference-example { display: grid; place-items: center; width: 55px; height: 55px; flex: 0 0 55px; border-radius: 15px; color: #fff; background: #17304d; font-size: 1.5rem; font-weight: 700; }

@media (min-width: 1500px) {
  .container { width: min(1180px, calc(100% - 48px)); }
  .hero__inner { width: min(1180px, calc(100% - 48px)); }
  .site-footer { padding-inline: max(24px, calc((100vw - 1180px) / 2)); }
}

@media (max-width: 900px) {
  .hero__inner { grid-template-columns: 1fr; gap: 18px; }
  .brand { max-width: 470px; }
  .brand-area { justify-content: flex-start; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .site-footer > p { text-align: right; }
  .result-header > div { grid-template-columns: 1fr; gap: 18px; }
}

@media (max-width: 720px) {
  .hero__inner { padding: 30px 0; }
  .steps { grid-template-columns: repeat(4, 1fr); row-gap: 6px; }
  .student-grid, .inline-grid, .inline-grid.three, .options { grid-template-columns: 1fr; }
  .student-grid label:last-child { max-width: none; }
  .rank-grid label { grid-template-columns: 1fr 100px; }
  .question legend { flex-wrap: wrap; }
  .question legend small { margin-inline-start: 41px; }
  .form-actions { flex-wrap: wrap; }
  .save-status { width: 100%; order: 3; text-align: center; }
  .intro-title, .result-title-row { align-items: stretch; flex-direction: column; }
  .lookup-card { grid-template-columns: 1fr; gap: 16px; }
  .lookup-form > div, .result-actions { flex-direction: column; }
  .score-breakdown, .result-details { grid-template-columns: 1fr; }
  .reference-row { grid-column: auto; }
  .final-score { width: 100%; min-height: 92px; }
  .button { min-height: 46px; text-align: center; }
}

@media (max-width: 480px) {
  .container, .result-container { width: min(calc(100% - 18px), 1060px); }
  .hero__inner { width: min(calc(100% - 24px), 1060px); }
  .hero h1 { font-size: 1.85rem; }
  .brand img { width: 120px; }
  .brand-area { align-items: stretch; flex-direction: column; gap: 10px; }
  .brand-logo { flex-basis: auto; width: 150px; }
  .language-switch { width: fit-content; }
  .brand small { font-size: .72rem; }
  .progress-shell { top: 4px; padding: 11px 10px 8px; border-radius: 12px; }
  .steps { display: flex; overflow-x: auto; justify-content: flex-start; padding-bottom: 3px; scrollbar-width: thin; }
  .steps li { min-width: 82px; }
  .form-step { padding: 17px 13px; border-radius: 14px; }
  .section-heading { gap: 10px; }
  .section-heading > span { width: 44px; height: 44px; flex-basis: 44px; border-radius: 12px; }
  .question legend { font-size: 1rem; }
  .option { align-items: flex-start; min-height: 48px; }
  .rank-grid label { grid-template-columns: 1fr; }
  .question legend small { margin-inline-start: 0; }
  .footer-brand { align-items: flex-start; flex-direction: column; }
  .footer-brand img { width: 105px; }
  .student-result { padding: 18px 13px; }
  .result-details > div { align-items: flex-start; flex-direction: column; gap: 2px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .progress-shell { position: static; }
}

@media print {
  @page { size: A4; margin: 13mm; }
  body { color: #111; background: #fff !important; font-family: Tahoma, Arial, sans-serif; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .hero, .progress-shell, .form-actions, footer, .no-print { display: none !important; }
  .container { width: 100%; margin: 0; }
  .form-step { display: block !important; box-shadow: none; break-before: page; }
  .form-step:first-of-type { break-before: auto; }
  .result-container { width: 100%; margin: 0; }
  .student-result { margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .print-brand { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 12mm; padding-bottom: 5mm; border-bottom: 2px solid #0f766e; }
  .print-brand img { width: 36mm; height: auto; max-height: 17mm; object-fit: contain; }
  .print-brand div { display: grid; text-align: left; }
  .print-brand span { color: #0f766e; font-size: 17pt; font-weight: 700; }
  .print-brand strong { font-size: 10pt; }
  .result-title-row { break-inside: avoid; }
  .score-breakdown, .result-details, .teacher-note { break-inside: avoid; }
  .print-signature { display: flex; justify-content: space-between; margin-top: 18mm; padding-top: 8mm; border-top: 1px solid #777; }
  .print-signature span { min-width: 45mm; }
  .print-footer { display: flex; justify-content: space-between; gap: 15mm; margin-top: 14mm; padding-top: 4mm; border-top: 1px solid #0f766e; color: #334155; font-size: 8.5pt; }
}
