:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #4b5260;
  --muted: #7a8090;
  --line: #e6e2da;
  --dark: #15171c;
  --dark-2: #23262e;
  --gold: #d9a521;
  --gold-ink: #2a1e00;
  --gold-soft: #fbf3dc;
  --ok: #1f7a4d;
  --ok-soft: #e5f4ec;
  --err: #b42318;
  --err-soft: #fdecea;
  --blue: #2457a6;
  --blue-soft: #e8eef9;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 20 30 / 6%), 0 6px 20px rgb(20 20 30 / 5%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Tajawal', Tahoma, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
}
img { display: block; max-width: 100%; }
a { color: var(--blue); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 6px; }
h1 { font-size: 28px; font-weight: 800; }
h1 small { font-size: 16px; font-weight: 500; color: var(--muted); margin-inline-start: 8px; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.center { text-align: center; }
.block { display: block; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px max(16px, 4vw);
  background: var(--dark); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; margin-inline-end: auto; }
.brand b { font-size: 20px; display: block; line-height: 1.1; }
.brand small { color: #a3a9b5; font-size: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--gold);
  box-shadow: inset 0 0 0 5px var(--dark), inset 0 0 0 14px var(--gold);
}
#nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
#nav a:not(.btn) { color: #d6d9df; text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 500; }
#nav a:not(.btn):hover, #nav a.active { background: var(--dark-2); color: #fff; }
#nav a.active { box-shadow: inset 0 -2px 0 var(--gold); }
.who { color: #fff; padding: 0 10px; font-weight: 700; border-inline-start: 1px solid #353944; margin-inline-start: 6px; }
.who small { color: var(--gold); font-weight: 500; margin-inline-start: 4px; }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }

/* ---------- الأزرار والنماذج ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: filter .15s, background .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold { background: var(--gold); color: var(--gold-ink); }
.btn-gold:hover:not(:disabled) { filter: brightness(1.06); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-outline { border-color: #4a4f5c; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.topbar .btn-ghost { color: #d6d9df; border-color: #353944; }
.btn-ghost:hover:not(:disabled) { background: rgb(0 0 0 / 4%); }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; }

label { display: block; font-weight: 500; font-size: 14px; color: var(--ink-2); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 11px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #d8d3c9; border-radius: 10px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .star:focus-visible { outline: 3px solid rgb(217 165 33 / 45%); outline-offset: 1px; }
.stack { display: grid; gap: 14px; }
.form-error { color: var(--err); min-height: 1.4em; margin: 4px 0; font-size: 14px; }

/* ---------- التخطيط ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 28px max(16px, 3vw) 64px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head-side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two-col > .panel { margin-bottom: 20px; }
.section-title { margin: 28px 0 14px; }
.section-title small { color: var(--muted); font-weight: 500; }
.comp-select { min-width: 220px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 60px 16px; }
.empty h1 { color: var(--ink); }
.note { background: var(--gold-soft); border: 1px solid #efd99a; border-radius: 12px; padding: 14px 16px; margin: 0 0 16px; }
.note.done { background: var(--ok-soft); border-color: #b8e0c8; color: var(--ok); font-weight: 700; }

/* ---------- الشارات ---------- */
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: #eee; color: var(--ink-2); white-space: nowrap; }
.st-draft { background: #eceae5; color: #5b5f69; }
.st-submission { background: var(--blue-soft); color: var(--blue); }
.st-judging { background: var(--gold-soft); color: #8a6200; }
.st-closed { background: var(--ok-soft); color: var(--ok); }
.badge.live { background: #fdecea; color: var(--err); }

/* ---------- الرئيسية ---------- */
.hero {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center;
  background: var(--dark); color: #fff; border-radius: 22px; padding: 48px;
}
.eyebrow { color: var(--gold); font-weight: 700; }
.hero h1 { font-size: 40px; margin: 8px 0 14px; }
.hero p { color: #c3c8d1; font-size: 18px; margin: 0 0 26px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.hero-steps li { display: flex; gap: 14px; align-items: flex-start; background: var(--dark-2); border-radius: 14px; padding: 16px; color: #c3c8d1; }
.hero-steps b { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--gold-ink); }
.hero-steps strong { color: #fff; }

/* ---------- الدخول ---------- */
.auth { max-width: 440px; margin: 30px auto; display: grid; gap: 14px; padding: 30px; }
.auth h2 { font-size: 24px; }

/* ---------- الرفع ---------- */
.upload-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.upload-form { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.drop {
  display: grid; place-items: center; min-height: 240px; padding: 16px;
  border: 2px dashed #cfc8ba; border-radius: 14px; background: #faf8f4;
  cursor: pointer; text-align: center; overflow: hidden;
}
.drop.over { border-color: var(--gold); background: var(--gold-soft); }
.drop small { display: block; color: var(--muted); margin-top: 4px; }
.drop img { max-height: 320px; border-radius: 8px; object-fit: contain; }
.upload-side { display: grid; gap: 14px; align-content: start; }
.progress { height: 8px; background: #ece8df; border-radius: 99px; overflow: hidden; flex: 1; }
.progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }

/* ---------- المعرض ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.tile, .podium-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.thumb { position: relative; aspect-ratio: 4 / 3; background: #e7e3db; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile-body { padding: 14px 16px 16px; display: grid; gap: 6px; justify-items: start; }
.score-line { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.stars-mini { color: #a77a00; font-weight: 700; }

/* ---------- التحكيم ---------- */
.judge-layout { display: grid; grid-template-columns: 1fr 150px; gap: 18px; align-items: start; }
.viewer { padding: 0; overflow: hidden; margin: 0; }
.viewer-img { background: #0e0f12; display: grid; place-items: center; height: min(62vh, 640px); }
.viewer-img img { max-height: 100%; max-width: 100%; object-fit: contain; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.pager { display: flex; align-items: center; gap: 8px; }
.rate { padding: 18px; display: grid; gap: 12px; }
.stars { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.star {
  font-size: 38px; line-height: 1; padding: 4px; background: none; border: 0; cursor: pointer;
  color: #d9d4c9; transition: transform .1s, color .1s;
}
.star.on { color: var(--gold); }
.star:hover:not(:disabled) { transform: scale(1.15); }
.locked .star { cursor: default; }
.rate-foot { display: flex; justify-content: center; align-items: center; gap: 22px; flex-wrap: wrap; }
.big-score { direction: ltr; display: flex; align-items: baseline; gap: 4px; }
.big-score b { font-size: 44px; font-weight: 800; min-width: 1.4em; text-align: center; }
.big-score span { color: var(--muted); }
.strip { display: flex; flex-direction: column; gap: 8px; max-height: calc(62vh + 190px); overflow-y: auto; padding: 2px; }
.strip-item { flex: none; position: relative; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; background: #ddd; aspect-ratio: 4 / 3; }
.strip-item img { width: 100%; height: 100%; object-fit: cover; }
.strip-item span { position: absolute; inset: auto 0 0 0; background: rgb(0 0 0 / 65%); color: #fff; font-size: 12px; padding: 2px 6px; font-weight: 700; }
.strip-item.rated img { opacity: .55; }
.strip-item.rated span { background: var(--ok); }
.strip-item.cur { border-color: var(--gold); }

/* ---------- النتائج ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.panel .stat { background: #faf8f4; }
.stat b { display: block; font-size: 28px; font-weight: 800; }
.stat span { color: var(--muted); font-size: 14px; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 22px; }
.medal {
  position: absolute; top: 10px; inset-inline-start: 10px;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 18px; background: #fff; box-shadow: 0 2px 8px rgb(0 0 0 / 25%);
}
.p1 .medal { background: #e3b333; }
.p2 .medal { background: #cfd3da; }
.p3 .medal { background: #d6945a; }
.p1 { border-color: #e3b333; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #faf8f4; font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td select { margin: 0; padding: 6px 8px; min-width: 100px; }
.rank { font-size: 22px; font-weight: 800; color: #a77a00; width: 64px; text-align: center; }
.cell-photo { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.cell-photo img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #ddd; }
.cell-photo small { display: block; }
.pct { display: inline-block; vertical-align: middle; width: 90px; height: 6px; background: #ece8df; border-radius: 99px; overflow: hidden; margin-inline-end: 8px; }
.pct span { display: block; height: 100%; background: var(--gold); }

/* ---------- الإدارة ---------- */
.status-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 10px; }
.step { padding: 12px 8px; border: 1px solid var(--line); background: #faf8f4; border-radius: 10px; font: inherit; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.step:hover { border-color: var(--gold); }
.step.cur { background: var(--dark); color: #fff; border-color: var(--dark); box-shadow: inset 0 -3px 0 var(--gold); }

/* ---------- الإشعارات ---------- */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 30px);
  background: var(--dark); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
  max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--err); }

/* ---------- الشاشات الصغيرة ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding: 28px 22px; gap: 24px; }
  .hero h1 { font-size: 30px; }
  .two-col, .upload-form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .podium { grid-template-columns: 1fr; }
  .judge-layout { grid-template-columns: 1fr; }
  .strip { flex-direction: row; overflow-x: auto; max-height: none; }
  .strip-item { width: 96px; }
  .viewer-img { height: 52vh; }
}
@media (max-width: 760px) {
  .menu-btn { display: block; }
  #nav { display: none; position: absolute; top: 100%; inset-inline: 0; background: var(--dark); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; border-top: 1px solid #2c2f38; }
  #nav.open { display: flex; }
  .who { border: 0; padding: 8px 12px; margin: 0; }
  h1 { font-size: 24px; }
  .wrap { padding-top: 20px; }
  .panel { padding: 16px; }
  .star { font-size: 28px; padding: 2px; }
  .status-steps { grid-template-columns: repeat(2, 1fr); }
  .comp-select { min-width: 0; width: 100%; }
  .page-head > div, .head-side { width: 100%; }
}

/* ---------- حقول التسجيل والتحقق ---------- */
.field-label { display: block; font-weight: 500; font-size: 14px; color: var(--ink-2); }
.phone-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 8px; }
.phone-row input { text-align: left; }
.code-input { font-size: 28px; letter-spacing: 10px; text-align: center; font-weight: 700; }
.verify-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; }
