/* ============ خطوة — Khatwa ============ */
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-ExtraBold.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }

:root {
  --teal: #0E6B68;
  --teal-700: #0A5452;
  --teal-50: #E3F1EF;
  --teal-25: #F2F8F7;
  --coral: #EF7A5A;
  --coral-700: #D65E3E;
  --coral-50: #FCE9E3;
  --gold: #F4B942;
  --navy: #2E4A62;
  --ink: #1F2A2A;
  --ink-2: #44514F;
  --mute: #6B7878;
  --line: #E1ECEA;
  --bg: #F7FAF9;
  --card: #FFFFFF;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(14, 107, 104, .06), 0 8px 24px rgba(14, 107, 104, .07);
  --shadow-lg: 0 20px 50px rgba(14, 107, 104, .16);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: "Tajawal", system-ui, sans-serif; color: var(--ink);
  background: var(--bg); line-height: 1.7; font-size: 16px;
}
img { max-width: 100%; display: block; }
a { color: var(--teal); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .4em; font-weight: 800; }
p { margin: 0 0 .8em; }
code { background: var(--teal-50); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--mute); }
.small { font-size: .88rem; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.center { text-align: center; }
.hide { display: none !important; }

/* ---------- topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--teal); }
.brand img { width: 40px; height: 40px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 1.35rem; font-weight: 800; }
.brand-text small { font-size: .7rem; letter-spacing: .25em; color: var(--coral); font-weight: 700; }
.mainnav { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
.mainnav > a { padding: 8px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; font-size: .95rem; }
.mainnav > a:hover { background: var(--teal-25); color: var(--teal); }
.mainnav > a.on { background: var(--teal-50); color: var(--teal); font-weight: 700; }
.mainnav .nav-admin { background: var(--navy); color: #fff !important; }
.mainnav .muted-link { color: var(--mute); }
.nav-user { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-inline-start: 1px solid var(--line); margin-inline-start: 6px; line-height: 1.2; }
.nav-user b { display: block; font-size: .9rem; }
.nav-user small { color: var(--mute); font-size: .78rem; }
.menu-btn { display: none; margin-inline-start: auto; background: var(--teal-50); color: var(--teal); border: 0; width: 42px; height: 42px; border-radius: 12px; font-size: 1.3rem; cursor: pointer; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 22px; border-radius: 14px; font-family: inherit; font-weight: 700; font-size: 1rem; border: 0; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; text-align: center; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 6px 16px rgba(14, 107, 104, .25); }
.btn-primary:hover { background: var(--teal-700); }
.btn-coral { background: var(--coral); color: #fff !important; box-shadow: 0 6px 16px rgba(239, 122, 90, .3); }
.btn-coral:hover { background: var(--coral-700); }
.btn-ghost { background: var(--teal-50); color: var(--teal); }
.btn-ghost:hover { background: #d4e9e6; }
.btn-white { background: #fff; color: var(--teal); }
.btn-outline { background: transparent; border: 1.5px solid var(--line); color: var(--ink-2); }
.btn-danger { background: #fdecec; color: #b42318; }
.btn-sm { padding: 7px 14px; font-size: .88rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; background: linear-gradient(160deg, var(--teal) 0%, #0b5f5c 55%, #0a4f4d 100%); color: #fff; padding: 56px 0 120px; }
.hero::after { content: ""; position: absolute; inset: auto 0 -1px 0; height: 70px; background: var(--bg); border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; position: relative; z-index: 1; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); margin-bottom: .3em; }
.hero h1 span { color: #FFD3C4; }
.hero p.lead { font-size: 1.15rem; opacity: .92; max-width: 34em; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); padding: 6px 14px; border-radius: 99px; font-size: .9rem; font-weight: 500; margin-bottom: 16px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #7CF5B4; box-shadow: 0 0 0 0 rgba(124, 245, 180, .7); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(124, 245, 180, .7); } 70% { box-shadow: 0 0 0 10px rgba(124, 245, 180, 0); } 100% { box-shadow: 0 0 0 0 rgba(124, 245, 180, 0); } }
.hero-card { background: #fff; color: var(--ink); border-radius: 24px; padding: 22px; box-shadow: var(--shadow-lg); }
.hero-card .big { font-size: clamp(2.2rem, 5vw, 3rem); font-weight: 800; color: var(--teal); line-height: 1.1; }
.hero-card .cap { color: var(--mute); font-size: .9rem; }
.hero-feet { position: absolute; inset: 0; pointer-events: none; opacity: .09; }
.challenge-bar { margin-top: 14px; }
.challenge-bar .track { height: 8px; border-radius: 99px; background: var(--teal-50); overflow: hidden; }
.challenge-bar .fill { height: 100%; background: linear-gradient(90deg, var(--coral), var(--gold)); border-radius: 99px; }
.challenge-bar .row { display: flex; justify-content: space-between; font-size: .85rem; color: var(--mute); margin-bottom: 6px; }

/* ---------- sections ---------- */
.section { padding: 36px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.6rem; margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--mute); }
.eyebrow { color: var(--coral); font-weight: 800; font-size: .85rem; letter-spacing: .05em; }
.pull-up { margin-top: -90px; position: relative; z-index: 2; }

/* ---------- cards & stats ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; border: 1px solid rgba(225, 236, 234, .7); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title h3 { margin: 0; font-size: 1.15rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid rgba(225, 236, 234, .7); }
.stat .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; background: var(--teal-50); margin-bottom: 10px; }
.stat.coral .ico { background: var(--coral-50); }
.stat.gold .ico { background: #FFF3D6; }
.stat.navy .ico { background: #E6ECF2; }
.stat .val { font-size: 1.8rem; font-weight: 800; color: var(--ink); line-height: 1.15; direction: ltr; text-align: right; }
.stat .lbl { color: var(--mute); font-size: .9rem; }
.stat .sub { font-size: .8rem; color: var(--teal); font-weight: 700; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-main { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }

/* ---------- tabs ---------- */
.tabs { display: inline-flex; background: var(--teal-50); padding: 4px; border-radius: 14px; gap: 2px; flex-wrap: wrap; }
.tabs button, .tabs a { border: 0; background: transparent; font-family: inherit; font-weight: 700; color: var(--teal); padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: .92rem; }
.tabs .on { background: #fff; box-shadow: 0 2px 8px rgba(14, 107, 104, .12); }

/* ---------- leaderboard ---------- */
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 14px; transition: background .3s; }
.lb li + li { border-top: 1px solid var(--line); }
.lb li.me { background: var(--coral-50); }
.lb li.flash { animation: flash 1.2s; }
@keyframes flash { 0% { background: #FFF3D6; } 100% { background: transparent; } }
.rank { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--teal-25); color: var(--teal); font-size: .95rem; }
.rank.r1 { background: linear-gradient(135deg, #FFD86B, #F4B942); color: #6b4a00; }
.rank.r2 { background: linear-gradient(135deg, #EEF2F4, #C9D3D8); color: #3e4a50; }
.rank.r3 { background: linear-gradient(135deg, #F8D2BE, #E5A07F); color: #6a3016; }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--teal); color: #fff; font-size: 1rem; }
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }
.avatar.coral { background: var(--coral); }
.avatar.team { border-radius: 12px; background: var(--navy); }
.lb .who { flex: 1; min-width: 0; line-height: 1.3; }
.lb .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb .who small { color: var(--mute); font-size: .8rem; }
.lb .score { text-align: left; line-height: 1.2; }
.lb .score b { font-size: 1.1rem; direction: ltr; display: block; }
.lb .score small { color: var(--mute); font-size: .75rem; }
.lb-bar { height: 5px; background: var(--teal-50); border-radius: 99px; margin-top: 5px; overflow: hidden; }
.lb-bar i { display: block; height: 100%; background: var(--teal); border-radius: 99px; transition: width .8s ease; }
.lb-empty { text-align: center; color: var(--mute); padding: 26px 10px; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 12px; align-items: end; margin-bottom: 18px; }
.podium .p { background: #fff; border-radius: 18px; padding: 16px 10px; text-align: center; box-shadow: var(--shadow); }
.podium .p .avatar { margin: 0 auto 8px; width: 52px; height: 52px; font-size: 1.2rem; }
.podium .p b { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium .p .s { font-weight: 800; color: var(--teal); direction: ltr; }
.podium .p1 { padding-top: 26px; border: 2px solid var(--gold); }
.podium .medal { font-size: 1.6rem; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 700; font-size: .92rem; color: var(--ink-2); }
.form small.hint { font-weight: 400; color: var(--mute); }
input, select, textarea { font-family: inherit; font-size: 1rem; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); width: 100%; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(14, 107, 104, .12); }
input[type=checkbox] { width: auto; }
.check { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px; font-weight: 500 !important; }
.steps-input { font-size: 2rem; font-weight: 800; text-align: center; direction: ltr; padding: 14px; letter-spacing: .03em; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 90px; display: block; cursor: pointer; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 10px 8px; border-radius: 12px; border: 1.5px solid var(--line); font-weight: 700; font-size: .9rem; }
.seg input:checked + span { border-color: var(--teal); background: var(--teal-50); color: var(--teal); }
.seg span small { display: block; font-weight: 400; color: var(--mute); font-size: .75rem; }

/* ---------- alerts ---------- */
.flashes { padding-top: 16px; }
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 10px; font-weight: 500; }
.alert-success { background: #E7F6EE; color: #1d6b43; }
.alert-error { background: #FDECEC; color: #a12a20; }
.alert-info { background: var(--teal-50); color: var(--teal-700); }
.alert-warn { background: #FFF6DF; color: #7a5600; }

/* ---------- auth ---------- */
.auth-body { background: linear-gradient(160deg, var(--teal-50), #fff 60%); }
.auth-wrap { min-height: calc(100vh - 66px); display: grid; place-items: center; padding: 30px 16px; }
.auth-card { width: 100%; max-width: 460px; background: #fff; border-radius: 24px; padding: 30px 26px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 1.6rem; text-align: center; }
.auth-card > .muted { text-align: center; }
.auth-logo { width: 200px; margin: 0 auto 14px; }
.auth-switch { text-align: center; margin-top: 16px; color: var(--mute); }

/* ---------- dashboard ---------- */
.welcome { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.welcome h1 { font-size: 1.7rem; margin: 0; }
.ring-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ring { position: relative; width: 170px; height: 170px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .in { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.15; }
.ring .in b { font-size: 2rem; font-weight: 800; direction: ltr; }
.ring .in small { color: var(--mute); font-size: .82rem; }
.ring circle { transition: stroke-dashoffset 1s ease; }
.kv { display: grid; gap: 8px; flex: 1; min-width: 180px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.kv span { color: var(--mute); }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { text-align: center; padding: 12px 6px; border-radius: 14px; background: var(--teal-25); border: 1px solid var(--line); }
.badge .e { font-size: 1.7rem; line-height: 1.2; }
.badge b { display: block; font-size: .82rem; }
.badge small { color: var(--mute); font-size: .72rem; display: block; line-height: 1.35; }
.badge.off { filter: grayscale(1); opacity: .45; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--teal-50); color: var(--teal); }
.tag.coral { background: var(--coral-50); color: var(--coral-700); }
.tag.gold { background: #FFF3D6; color: #7a5600; }
.tag.gray { background: #EEF1F1; color: var(--mute); }
.tag.red { background: #FDECEC; color: #a12a20; }
.list-rows { display: grid; gap: 8px; }
.list-rows .r { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--teal-25); }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

/* ---------- team ---------- */
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--teal-25); border: 2px dashed var(--teal); border-radius: 16px; padding: 12px 16px; }
.code-box code { font-size: 1.8rem; font-weight: 800; letter-spacing: .25em; background: none; color: var(--teal); direction: ltr; }
.slots { display: flex; gap: 8px; margin: 10px 0; }
.slots i { flex: 1; height: 10px; border-radius: 99px; background: var(--line); }
.slots i.on { background: var(--teal); }
.slots i.min { background: var(--coral); }

/* ---------- walk mode ---------- */
.walk-body { background: linear-gradient(170deg, var(--teal) 0%, #0a4f4d 100%); color: #fff; }
.walk-body .page { min-height: calc(100vh - 66px); }
.walk { max-width: 520px; margin: 0 auto; padding: 26px 16px 40px; text-align: center; }
.walk-counter { position: relative; width: 270px; height: 270px; margin: 18px auto; }
.walk-counter svg { transform: rotate(-90deg); }
.walk-counter .in { position: absolute; inset: 0; display: grid; place-content: center; }
.walk-counter .in b { font-size: 4rem; font-weight: 800; line-height: 1; direction: ltr; }
.walk-counter .in small { opacity: .8; }
.walk-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 22px; }
.walk-stats div { background: rgba(255, 255, 255, .1); border-radius: 14px; padding: 10px 6px; }
.walk-stats b { display: block; font-size: 1.35rem; direction: ltr; }
.walk-stats small { opacity: .8; font-size: .8rem; }
.walk .btn-big { width: 100%; padding: 18px; font-size: 1.25rem; border-radius: 18px; }
.walk-note { background: rgba(255, 255, 255, .1); border-radius: 14px; padding: 12px 14px; font-size: .9rem; text-align: right; margin-top: 18px; line-height: 1.7; }
.walk-status { min-height: 1.6em; font-weight: 700; color: #FFD3C4; }
.steps-pulse { animation: stepPulse .25s; }
@keyframes stepPulse { 50% { transform: scale(1.06); } }

/* ---------- how ---------- */
.how-step { display: flex; gap: 16px; align-items: flex-start; }
.how-step .n { width: 44px; height: 44px; flex: none; border-radius: 14px; background: var(--coral); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; }
.app-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.app-grid .card h4 { margin-bottom: 6px; }
.app-grid ol { margin: 0; padding-inline-start: 18px; color: var(--ink-2); font-size: .93rem; }

/* ---------- features ---------- */
.feature { display: flex; gap: 14px; }
.feature .ico { width: 52px; height: 52px; flex: none; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; background: var(--teal-50); }
.feature h3 { font-size: 1.1rem; margin-bottom: 4px; }
.feature p { color: var(--mute); margin: 0; font-size: .95rem; }
.cta-band { background: linear-gradient(120deg, var(--coral), #f39a6f); color: #fff; border-radius: 24px; padding: 30px; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.cta-band h2 { margin: 0 0 4px; }
.cta-band p { margin: 0; opacity: .95; }

/* ---------- tables (admin) ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.t th { text-align: right; color: var(--mute); font-weight: 700; padding: 10px; border-bottom: 2px solid var(--line); white-space: nowrap; font-size: .85rem; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:hover td { background: var(--teal-25); }
table.t td.num { font-weight: 700; display: table-cell; direction: ltr; text-align: right; }

/* ---------- admin layout ---------- */
.admin-body { background: #F3F6F6; }
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 66px); }
.admin-side { background: #fff; border-inline-end: 1px solid var(--line); padding: 20px 14px; }
.admin-side a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }
.admin-side a.on { background: var(--teal); color: #fff; }
.admin-side a:hover:not(.on) { background: var(--teal-25); }
.admin-side .sep { height: 1px; background: var(--line); margin: 12px 0; }
.admin-main { padding: 24px; min-width: 0; }
.admin-main h1 { font-size: 1.6rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; padding: 9px 12px; }
.goal-meter { display: grid; gap: 6px; }
.goal-meter .track { height: 12px; border-radius: 99px; background: var(--teal-50); overflow: hidden; }
.goal-meter .fill { height: 100%; background: var(--teal); border-radius: 99px; }
.goal-meter .fill.coral { background: var(--coral); }
.goal-meter .row { display: flex; justify-content: space-between; font-size: .88rem; }
.insight { border-inline-start: 4px solid var(--coral); background: var(--coral-50); padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-size: .93rem; }
.proof-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- footer ---------- */
.footer { background: #0a3f3d; color: #cfe3e0; margin-top: 40px; padding-top: 34px; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; padding-bottom: 24px; }
.footer-brand img { width: 170px; background: #fff; border-radius: 14px; padding: 8px 10px; margin-bottom: 12px; }
.footer-brand p { font-size: .93rem; opacity: .85; max-width: 32em; }
.footer-links { display: grid; gap: 6px; align-content: start; font-size: .93rem; }
.footer-links b { color: #fff; margin-bottom: 4px; }
.footer-links a { color: #cfe3e0; }
.footer-links .muted { color: #8fb3ae; font-size: .82rem; }
.footer-bottom { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px solid rgba(255, 255, 255, .1); padding: 14px 16px 20px; font-size: .85rem; opacity: .8; }

/* ---------- bottom nav (mobile, logged in) ---------- */
.bottomnav { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .hero-grid, .grid-main { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .app-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
  .admin { grid-template-columns: 1fr; }
  .admin-side { display: flex; overflow-x: auto; gap: 6px; padding: 10px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .admin-side a { white-space: nowrap; margin: 0; }
  .admin-side .sep { display: none; }
}
@media (max-width: 820px) {
  .menu-btn { display: block; }
  .mainnav { display: none; position: absolute; top: 66px; inset-inline: 0; background: #fff; flex-direction: column; align-items: stretch; padding: 10px 16px 16px; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  .mainnav.open { display: flex; }
  .mainnav > a { padding: 12px; }
  .nav-user { border: 0; margin: 6px 0; padding: 8px 12px; background: var(--teal-25); border-radius: 12px; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .hero { padding: 34px 0 100px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { gap: 10px; }
  .stat { padding: 14px; }
  .stat .val { font-size: 1.45rem; }
  .card { padding: 18px; border-radius: 16px; }
  .badges { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .podium .p .avatar { width: 42px; height: 42px; }
  .ring { width: 150px; height: 150px; }
  .ring svg { width: 150px; height: 150px; }
  .admin-main { padding: 16px; }
  .footer-inner { grid-template-columns: 1fr; }
  .has-bottom-nav .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; z-index: 60; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(14, 107, 104, .08); }
  .bottomnav a { display: grid; justify-items: center; font-size: .72rem; color: var(--mute); font-weight: 700; gap: 2px; padding: 4px 0; }
  .bottomnav a span { font-size: 1.25rem; line-height: 1; }
  .bottomnav a.on { color: var(--teal); }
  .bottomnav .walk-fab span { background: var(--coral); width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-top: -22px; box-shadow: 0 6px 16px rgba(239, 122, 90, .4); border: 3px solid #fff; }
  .has-bottom-nav .footer { padding-bottom: 80px; }
}

/* ---------- إصلاح عرض الجوال: منع تمدد الأعمدة بسبب الرسوم والجداول ---------- */
.grid-2, .grid-3, .grid-main, .stats-grid, .admin { min-width: 0; }
.grid-2 > *, .grid-3 > *, .grid-main > *, .stats-grid > *, .admin > *, .card, .chart-box { min-width: 0; }
.chart-box canvas { max-width: 100%; }
@media (max-width: 960px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .admin-side { position: sticky; top: 66px; z-index: 20; }
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-main h1 { font-size: 1.35rem; }
  .admin-main .toolbar { gap: 8px; }
  .admin-main .toolbar form, .admin-main .toolbar input, .admin-main .toolbar select { width: 100%; min-width: 0; }
  .admin-main .toolbar .tabs { width: 100%; }
  .admin-main .welcome { align-items: flex-start; }
  .stat .lbl { font-size: .82rem; }
  .stat .sub { font-size: .74rem; }
  .chart-box { height: 230px; }
  .chart-box.tall { height: 260px; }
  table.t { font-size: .85rem; }
  table.t th, table.t td { padding: 8px 6px; }
  .goal-meter .row { font-size: .82rem; gap: 8px; }
}

/* ---------- سفاري آيفون: ترتيب عمودي لبطاقة خطوات اليوم + منع أي تمدد أفقي ---------- */
html, body { max-width: 100%; overflow-x: clip; }
.ring-wrap > * { min-width: 0; }
.kv { min-width: 0; }
@media (max-width: 640px) {
  .ring-wrap { flex-direction: column; align-items: stretch; gap: 16px; }
  .ring { margin: 0 auto; }
  .kv { width: 100%; }
  .welcome { flex-direction: column; align-items: stretch; }
  .welcome .btn { width: 100%; }
  .welcome h1 { font-size: 1.45rem; overflow-wrap: anywhere; }
  .seg label { min-width: 0; }
  .code-box code { font-size: 1.4rem; letter-spacing: .18em; }
  .walk-counter { width: 240px; height: 240px; }
  .walk-counter svg { width: 240px; height: 240px; }
  .walk-counter .in b { font-size: 3.4rem; }
}
/* هامش جانبي ثابت للصفحات اللي تجمع container + section */
.container.section { padding-left: 16px; padding-right: 16px; }
