/* منصة القياس: ألوان اللقاء (أزرق بترولي عميق، أخضر مزرق، ونحاسي للتنبيه) */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f2;
  --ink: #12343b;
  --ink-2: #4a5d61;
  --line: #d9e2e0;
  --brand: #1f6f64;
  --brand-ink: #ffffff;
  --brand-soft: #dcefeb;
  --accent: #b5543a;
  --accent-soft: #f7e3dc;
  --lo: #b5543a; --lo-bg: #f7e3dc;
  --mid: #8a6a12; --mid-bg: #f5ecd0;
  --hi: #1f6f64; --hi-bg: #dcefeb;
  --pre: #8fb3ad;
  --post: #12343b;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --display: "Readex Pro", "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1a1d; --surface: #152428; --surface-2: #1b2e33; --ink: #e8f0ee; --ink-2: #a9bcb9;
    --line: #2a4046; --brand: #4fb3a3; --brand-ink: #0b1a1c; --brand-soft: #1d3a37;
    --accent: #e48a6d; --accent-soft: #3a2621;
    --lo: #ef9a80; --lo-bg: #3a2621; --mid: #e3c56a; --mid-bg: #352d16; --hi: #6fd0c0; --hi-bg: #1d3a37;
    --pre: #4d7a74; --post: #9fe0d5;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.7 var(--font);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
}
h1, h2, h3 { font-family: var(--display); line-height: 1.35; margin: 0; text-wrap: balance; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-size: .8rem; font-weight: 600; color: var(--brand); letter-spacing: .02em; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 .95rem var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn.on { background: var(--brand-soft); border-color: var(--brand); }
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--brand); font: 600 .85rem var(--font); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--accent); }

.alert { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.pill { display: inline-block; font-size: .8rem; font-weight: 700; padding: 3px 12px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.pill-pre { background: var(--brand-soft); color: var(--brand); }
.pill-post { background: var(--accent-soft); color: var(--accent); }
.chip { display: inline-block; font-size: .78rem; font-weight: 700; padding: 1px 10px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.chip-lo { background: var(--lo-bg); color: var(--lo); }
.chip-mid { background: var(--mid-bg); color: var(--mid); }
.chip-hi { background: var(--hi-bg); color: var(--hi); }
.chip-none { color: var(--ink-2); }

/* ---------- صفحة المشارك ---------- */
.p-wrap { max-width: 680px; margin: 0 auto; padding-block: 28px 120px; display: grid; gap: 16px; }
.p-head { display: grid; gap: 4px; padding-inline: 4px; }
.p-head h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 12px; }
.card.center { text-align: center; justify-items: center; padding-block: 36px; }
.card h2 { font-size: 1.25rem; }
.state-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: var(--surface-2); color: var(--ink-2); }
.state-icon.ok { background: var(--brand-soft); color: var(--brand); }
.phone-form { display: grid; gap: 10px; }
.phone-form label, .open-label { font-weight: 600; }
.phone-form input, textarea, .newsess input, .rename input, select {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: 1.05rem var(--font);
}
.phone-form input[type=tel] { font-size: 1.3rem; letter-spacing: .08em; text-align: center; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 96px; }
.fine { font-size: .85rem; color: var(--ink-2); text-align: center; }

.survey { display: grid; gap: 16px; }
.scale-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--ink-2); }
fieldset.dim { margin: 0; min-width: 0; }
fieldset.dim legend { padding: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.dim-name { font-family: var(--display); font-weight: 700; font-size: 1.15rem; color: var(--brand); }
.dim-q { color: var(--ink-2); font-size: .9rem; }
.item { display: grid; gap: 10px; padding-block: 14px; border-top: 1px solid var(--line); border-radius: 8px; transition: background .3s; }
.item.missing { background: var(--accent-soft); padding-inline: 10px; }
.stmt { font-weight: 500; display: flex; gap: 10px; }
.stmt .num, .n-text .num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); margin-top: 2px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale label {
  display: grid; justify-items: center; gap: 2px; padding: 8px 2px; min-height: 64px; align-content: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s;
}
.scale label b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.scale label span { font-size: .7rem; line-height: 1.25; color: var(--ink-2); }
.scale label:hover { border-color: var(--brand); }
.scale input:checked + label { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.scale input:checked + label span { color: var(--brand-ink); }
.scale input:focus-visible + label { outline: 3px solid var(--brand); outline-offset: 2px; }
.submit-bar {
  position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 24px rgb(0 0 0 / .08);
}
.progress { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s; }

/* ---------- صفحة QR ---------- */
.qr-wrap { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px; text-align: center; padding-block: 32px; }
.qr-wrap h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); }
.qr-box { background: #fff; padding: 18px; border-radius: 18px; border: 1px solid var(--line); }
.qr-box img, .qr-box canvas { display: block; max-width: 100%; height: auto; }
.qr-link { font-size: clamp(1rem, 2.4vw, 1.5rem); font-weight: 600; word-break: break-all; }

/* ---------- لوحة المدرب ---------- */
body.admin { padding-left: 0; padding-right: 0; }
.a-top { background: var(--ink); color: var(--bg); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (prefers-color-scheme: dark) { .a-top { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); } }
.a-top-in { max-width: 1180px; margin: 0 auto; padding-block: 16px; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.a-brand { flex: 1 1 260px; min-width: 0; }
.a-brand .eyebrow { color: #9fe0d5; }
.a-brand h1 { font-size: 1.35rem; }
.a-session { flex: 0 1 300px; min-width: 0; }
.a-session select { min-height: 42px; font-size: .95rem; }
.a-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.a-actions form { margin: 0; }
.a-top .btn { background: transparent; color: inherit; border-color: rgb(255 255 255 / .25); }
.a-top .btn.on { background: rgb(255 255 255 / .14); }
@media (prefers-color-scheme: dark) { .a-top .btn { border-color: var(--line); } }

.a-wrap { max-width: 1180px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 64px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 14px; min-width: 0; }
.panel h2 { font-size: 1.15rem; }
.sec-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.sub { font-size: 1rem; margin-top: 8px; }

.control { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.control > div { display: grid; gap: 10px; align-content: start; min-width: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg-b { min-height: 48px; border: 0; background: var(--surface); color: var(--ink); font: 700 .95rem var(--font); cursor: pointer; border-inline-start: 1px solid var(--line); }
.seg-b:first-child { border-inline-start: 0; }
.seg-b.on { background: var(--brand); color: var(--brand-ink); }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 6px 6px 6px 6px; min-width: 0; }
.linkbox code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 600 .95rem ui-monospace, Menlo, Consolas, monospace; padding-inline: 8px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; display: grid; gap: 2px; }
.kpi.wide { grid-column: span 2; }
@media (max-width: 520px) { .kpi.wide { grid-column: 1 / -1; } }
.k-l { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
.k-v { font: 700 2rem/1.2 var(--display); font-variant-numeric: tabular-nums; }
.k-v .arrow { color: var(--ink-2); font-weight: 400; font-size: 1.4rem; }
.k-s { font-size: .85rem; color: var(--ink-2); }
.up { color: var(--hi); }
.down { color: var(--lo); }

.empty { text-align: center; justify-items: center; padding-block: 36px; }

.focus-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.focus-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 8px; align-content: start; background: var(--surface); }
.focus-card.primary { background: var(--accent-soft); border-color: transparent; }
.focus-card.follow { background: var(--surface-2); border-color: transparent; }
.f-rank { font-size: .8rem; font-weight: 700; color: var(--accent); }
.focus-card.follow .f-rank { color: var(--brand); }
.focus-card h3 { font-size: 1.2rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.f-num b { font: 700 1.4rem var(--display); font-variant-numeric: tabular-nums; }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .85rem; color: var(--ink-2); }
.sw { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }
.sw.pre { background: var(--pre); } .sw.post { background: var(--post); } .sw.tgt { width: 3px; height: 14px; background: var(--accent); }
.dimchart { display: grid; gap: 12px; }
.axis { position: relative; height: 18px; margin-inline-start: 120px; font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.axis span { position: absolute; transform: translateX(50%); }
.drow { display: grid; grid-template-columns: 108px 1fr; gap: 12px; align-items: center; }
.dname { font-weight: 600; }
.track { position: relative; display: grid; gap: 4px; padding-block: 6px; min-height: 52px; align-content: center; }
.zone { position: absolute; top: 0; bottom: 0; }
.z-lo { inset-inline-start: 0; width: 37.5%; background: var(--lo-bg); opacity: .55; border-start-start-radius: 8px; border-end-start-radius: 8px; }
.z-mid { inset-inline-start: 37.5%; width: 37.5%; background: var(--mid-bg); opacity: .55; }
.z-hi { inset-inline-start: 75%; width: 25%; background: var(--hi-bg); opacity: .55; border-start-end-radius: 8px; border-end-end-radius: 8px; }
.tline { position: absolute; top: -4px; bottom: -4px; inset-inline-start: 75%; width: 3px; background: var(--accent); border-radius: 2px; }
.bar { position: relative; height: 18px; border-radius: 0 6px 6px 0; min-width: 2px; }
[dir=rtl] .bar { border-radius: 6px 0 0 6px; }
.bar.pre { background: var(--pre); }
.bar.post { background: var(--post); }
.bar span { position: absolute; inset-inline-start: calc(100% + 6px); top: 50%; transform: translateY(-50%); font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
@media (max-width: 520px) {
  .drow { grid-template-columns: 1fr; gap: 2px; }
  .axis { margin-inline-start: 0; }
}

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; min-width: 640px; font-size: .92rem; }
.tbl th, .tbl td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl thead th { background: var(--surface-2); font-size: .82rem; color: var(--ink-2); font-weight: 700; }
.tbl tbody tr:last-child > * { border-bottom: 0; }
.tbl small { font-weight: 500; }
.students .phone { font-variant-numeric: tabular-nums; font-weight: 600; text-align: end; }
.del { white-space: nowrap; }
.delform { display: inline; margin: 0; }

.dist { display: grid; gap: 10px; }
.dist-row { display: grid; grid-template-columns: 108px 1fr; gap: 12px; align-items: center; }
.stack { display: flex; height: 34px; border-radius: 8px; overflow: hidden; background: var(--surface-2); min-width: 0; }
.stack span { display: grid; place-items: center; font-size: .78rem; font-weight: 700; white-space: nowrap; overflow: hidden; min-width: 0; }
.seg-lo { background: var(--lo-bg); color: var(--lo); }
.seg-mid { background: var(--mid-bg); color: var(--mid); }
.seg-hi { background: var(--hi-bg); color: var(--hi); }
.stack .none { padding-inline: 12px; color: var(--ink-2); font-weight: 500; }
@media (max-width: 520px) { .dist-row { grid-template-columns: 1fr; gap: 4px; } }

.needs { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.needs li { display: flex; gap: 14px; justify-content: space-between; align-items: center; padding-block: 12px; border-top: 1px solid var(--line); }
.needs li:first-child { border-top: 0; }
.n-main { display: grid; gap: 4px; min-width: 0; }
.n-text { display: flex; gap: 10px; font-weight: 500; }
.n-score { text-align: end; flex: none; font-variant-numeric: tabular-nums; }
.n-score b { font: 700 1.3rem var(--display); color: var(--accent); }

.opens { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.opens li { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; align-content: start; }
.opens li .pill { justify-self: start; }
.opens p { overflow-wrap: anywhere; }

.newsess { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.newsess label { font-weight: 600; }
.newsess input { flex: 1 1 260px; width: auto; }
.sess-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.sess-list li { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding-block: 10px; border-top: 1px solid var(--line); }
.sess-list form { margin: 0; display: flex; gap: 6px; align-items: center; }
.rename { flex: 1 1 260px; min-width: 0; }
.rename .link-btn { white-space: nowrap; }
.rename input { min-height: 38px; font-size: .95rem; padding: 6px 10px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
