:root {
  --navy: #0B1B3F;
  --navy-2: #13306B;
  --orange: #E8742A;
  --orange-d: #C85A14;
  --gold: #F5C542;
  --paper: #F3F5FA;
  --ink: #16213A;
  --muted: #5B6680;
  --line: #D9DFEB;
  --ok: #1E8E5A;
  --bad: #C43B3B;
  --card: #FFFFFF;
  --display: 'Lalezar', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--body); color: var(--ink); background: var(--paper);
  line-height: 1.6; font-size: 16px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; font-weight: 400; }
.muted { color: var(--muted); font-size: .92rem; margin: .25rem 0 1.25rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ===== الواجهة العامة ===== */
.hero {
  background:
    radial-gradient(circle at 85% 20%, rgba(232,116,42,.35), transparent 45%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: calc(2rem + env(safe-area-inset-top, 0px)) 1.25rem 7rem;
  display: grid; gap: 2rem; justify-items: center;
}
.hero-inner { max-width: 640px; width: 100%; }
.org { font-size: .88rem; opacity: .85; margin: 0 0 .75rem; max-width: 36em; }
.hero h1 {
  font-family: var(--display); font-size: clamp(2.6rem, 11vw, 4.4rem); line-height: 1.05;
  color: #fff; text-shadow: 0 3px 0 var(--orange-d);
}
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1.5rem 0 1rem; }
.facts div { border-top: 3px solid var(--gold); padding-top: .5rem; }
.facts span { display: block; font-size: .78rem; opacity: .75; }
.facts strong { font-size: .95rem; font-weight: 600; line-height: 1.35; display: block; }
.deadline {
  display: inline-block; background: var(--gold); color: var(--navy); font-weight: 700;
  padding: .3rem .8rem; border-radius: 4px; margin: 0; font-size: .92rem;
}
.poster {
  width: min(420px, 100%); border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45); transform: rotate(-1.5deg);
}

.sheet {
  max-width: 640px; margin: -5rem auto 0; padding: 0 1rem; position: relative;
}
form#regForm, .state {
  background: var(--card); border-radius: 14px; padding: 1.75rem 1.25rem;
  box-shadow: 0 10px 30px rgba(11,27,63,.12);
  border-top: 6px solid var(--orange);
}
.form-title { font-family: var(--display); font-size: 2rem; color: var(--navy); }

.field { border: 0; padding: 0; margin: 0 0 1.2rem; min-width: 0; }
.field > label, .field > legend { display: block; font-weight: 600; margin-bottom: .4rem; padding: 0; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: 8px; padding: .75rem .85rem; min-height: 48px;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--navy-2); outline: none; box-shadow: 0 0 0 3px rgba(19,48,107,.15); }
input[type=tel] { text-align: right; letter-spacing: .05em; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.tile, .pill { position: relative; cursor: pointer; }
.tile input, .pill input, .chk input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.tile span, .pill span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 56px; padding: .5rem; border: 1.5px solid var(--line); border-radius: 8px;
  font-weight: 500; line-height: 1.3; transition: all .15s;
}
.tile input:checked + span, .pill input:checked + span {
  background: var(--navy); border-color: var(--navy); color: #fff;
  box-shadow: inset 0 -4px 0 var(--orange);
}
.tile input:focus-visible + span, .pill input:focus-visible + span, .chk input:focus-visible + span { outline: 3px solid var(--gold); }
.pills { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.pill span { min-height: 48px; }

.err { color: var(--bad); font-size: .85rem; display: block; min-height: 0; margin-top: .3rem; }
.err:empty { display: none; }
.invalid input, .invalid select, .invalid .tile span, .invalid .pill span { border-color: var(--bad); }
.hp { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); pointer-events: none; }
body { overflow-x: hidden; }
.form-msg { color: var(--bad); font-weight: 600; margin-bottom: .75rem; }
.form-msg:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 700; border: 0; border-radius: 8px; cursor: pointer;
  padding: .85rem 1.4rem; min-height: 48px; text-decoration: none; transition: transform .1s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); color: #fff; width: 100%; font-size: 1.1rem; box-shadow: 0 4px 0 var(--orange-d); }
.btn.primary:hover { background: #F07F35; }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; border: 1.5px solid var(--navy); color: var(--navy); }

.state { text-align: center; }
.state h2 { font-family: var(--display); font-size: 2.2rem; color: var(--navy); margin-top: 1rem; }
.state p { margin: .4rem 0; }
.serial {
  font-family: var(--display); font-size: 4.5rem; line-height: 1; color: var(--orange);
  margin: .25rem 0 1rem;
}
.state.closed { border-top-color: var(--muted); }

/* كرة سلة مرسومة بالـ CSS */
.ball {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 35% 30%, #F59A55, var(--orange) 55%, var(--orange-d));
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.15);
}
.ball::before, .ball::after { content: ""; position: absolute; inset: 0; border-radius: 50%; }
.ball::before { background: linear-gradient(90deg, transparent 47%, #3A1D0A 47% 53%, transparent 53%), linear-gradient(0deg, transparent 47%, #3A1D0A 47% 53%, transparent 53%); }
.ball::after { border: 3px solid transparent; border-left-color: #3A1D0A; border-right-color: #3A1D0A; transform: scaleX(.55); }
.done .ball { animation: bounce .9s cubic-bezier(.3,.6,.4,1) 2; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-26px); } }

.foot { text-align: center; color: var(--muted); font-size: .88rem; padding: 2rem 1rem 2.5rem; }
.foot p { margin: .2rem 0; }
.foot a { color: var(--navy-2); font-weight: 600; white-space: nowrap; }

@media (min-width: 900px) {
  .hero { grid-template-columns: 1fr 380px; align-items: center; max-width: none; padding-inline: max(2rem, calc((100vw - 1100px) / 2)); padding-bottom: 8rem; }
  .poster { justify-self: start; }
}
@media (max-width: 480px) {
  .row { grid-template-columns: 1fr; }
  .facts strong { font-size: .85rem; }
}

/* ===== صفحة النتائج ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--navy), var(--navy-2)); }
.login {
  background: #fff; border-radius: 14px; padding: 2rem 1.5rem; width: min(380px, 100%); text-align: center;
  border-top: 6px solid var(--orange);
}
.login h1 { font-family: var(--display); font-size: 2rem; color: var(--navy); margin-top: .75rem; }
.login label { display: block; text-align: right; font-weight: 600; margin-bottom: .35rem; }
.login input { text-align: center; font-size: 1.4rem; letter-spacing: .4em; margin-bottom: 1rem; }

.topbar {
  background: var(--navy); color: #fff; padding: calc(1rem + env(safe-area-inset-top, 0px)) 1rem 1rem;
  display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-family: var(--display); font-size: 1.6rem; line-height: 1.1; }
.topbar p { margin: 0; font-size: .82rem; opacity: .75; }
.top-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.btn.small { padding: .45rem .8rem; min-height: 38px; font-size: .85rem; }
.btn.ghost-light { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25); }
.btn.open { background: var(--ok); color: #fff; }
.btn.closed { background: var(--bad); color: #fff; }

.board { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.stat { background: #fff; border-radius: 10px; padding: .65rem .5rem; text-align: center; border-bottom: 3px solid var(--line); }
.stat:first-child { background: var(--navy); color: #fff; border-color: var(--orange); }
.stat strong { display: block; font-family: var(--display); font-size: 1.6rem; line-height: 1.1; font-weight: 400; }
.stat span { font-size: .8rem; color: inherit; opacity: .75; }
.stat-cats { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; color: var(--muted); padding: .2rem .25rem; }
.stat-cats b { color: var(--ink); }

.filters { background: #fff; border-radius: 10px; padding: .75rem; margin-bottom: 1rem; }
.filter-row { display: flex; gap: .4rem; overflow-x: auto; margin-top: .5rem; padding-bottom: .2rem; }
.filter-row select { width: auto; min-width: 130px; flex: 0 0 auto; min-height: 42px; padding: .4rem .6rem; font-size: .88rem; }
.count { margin: .5rem 0 0; font-size: .85rem; color: var(--muted); }

.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .75rem; }
.card {
  background: #fff; border-radius: 10px; padding: .9rem; border-right: 5px solid var(--line);
  display: grid; gap: .6rem;
}
.card.st-accepted { border-right-color: var(--ok); }
.card.st-rejected { border-right-color: var(--bad); opacity: .82; }
.card-head { display: flex; gap: .7rem; align-items: flex-start; }
.sn {
  flex: 0 0 auto; min-width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--orange); color: #fff; font-family: var(--display); font-size: 1.2rem; padding: 0 .3rem;
}
.who h3 { font-size: 1.05rem; font-weight: 700; line-height: 1.35; }
.who p { margin: 0; font-size: .82rem; color: var(--muted); }
.contact { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.contact a { color: var(--navy-2); font-weight: 600; text-decoration: none; }
.contact .wa { background: #E7F7EE; color: #127A45; padding: .15rem .6rem; border-radius: 20px; font-size: .82rem; }
.contact .time { margin-inline-start: auto; font-size: .78rem; color: var(--muted); }

.marks { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: .8rem; border: 0; background: #fff; color: var(--muted); padding: .4rem .6rem; cursor: pointer; min-height: 36px; }
.seg button + button { border-right: 1.5px solid var(--line); }
.seg button.on.review { background: var(--gold); color: var(--navy); font-weight: 700; }
.seg button.on.accepted { background: var(--ok); color: #fff; font-weight: 700; }
.seg button.on.rejected { background: var(--bad); color: #fff; font-weight: 700; }
.chk { position: relative; cursor: pointer; }
.chk span {
  display: inline-flex; align-items: center; gap: .3rem; min-height: 36px; padding: .3rem .7rem;
  border: 1.5px solid var(--line); border-radius: 8px; font-size: .82rem; color: var(--muted);
}
.chk span::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-radius: 3px; }
.chk input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.chk input:checked + span::before { background: var(--gold); border-color: var(--gold); }
.note { min-height: 38px; padding: .4rem .6rem; font-size: .88rem; }
.card-actions { display: flex; gap: 1rem; justify-content: flex-end; }
.link { background: none; border: 0; font: inherit; font-size: .85rem; font-weight: 600; color: var(--navy-2); cursor: pointer; padding: .2rem; }
.link.danger { color: var(--bad); }
.empty { grid-column: 1 / -1; background: #fff; border: 2px dashed var(--line); border-radius: 10px; padding: 2rem; text-align: center; color: var(--muted); }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(440px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(11,27,63,.6); }
#editForm { padding: 1.25rem; display: grid; gap: .6rem; }
#editForm h2 { font-family: var(--display); font-size: 1.5rem; color: var(--navy); }
#editForm label { font-weight: 600; font-size: .88rem; display: grid; gap: .25rem; }
.dlg-actions { display: flex; gap: .5rem; }
.dlg-actions .btn { flex: 1; font-size: 1rem; }

.toast {
  position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translate(-50%, 150%);
  background: var(--navy); color: #fff; padding: .6rem 1.2rem; border-radius: 30px; font-size: .9rem;
  transition: transform .25s, opacity .25s; z-index: 20; opacity: 0; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.print-table { display: none; }
@media print {
  .topbar, .filters, .list, .toast, .stats { display: none !important; }
  body { background: #fff; }
  .board::before { content: "كشف المتقدمين – الدورة التدريبية بكرة السلة – الديوانية 2026"; display: block; font-weight: 700; font-size: 14pt; margin-bottom: 8pt; }
  .print-table { display: table; width: 100%; border-collapse: collapse; font-size: 9pt; }
  .print-table th, .print-table td { border: 1px solid #999; padding: 3pt 4pt; text-align: right; }
  .print-table th { background: #eee; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
