/* «أثر» — نظام التصميم: الخطوط ← المتغيرات ← المكونات ← إضافات التطبيق */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-ar-400.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F, U+066A; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/plex-ar-500.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F, U+066A; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-ar-600.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F, U+066A; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/plex-ar-700.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F, U+066A; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-lat-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-lat-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/plex-lat-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Readex"; font-weight: 600; font-display: swap; src: url(../fonts/readex-ar-600.woff2) format("woff2"); unicode-range: U+0600-06FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Readex"; font-weight: 700; font-display: swap; src: url(../fonts/readex-ar-700.woff2) format("woff2"); unicode-range: U+0600-06FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Readex"; font-weight: 600; font-display: swap; src: url(../fonts/readex-lat-600.woff2) format("woff2"); unicode-range: U+0000-00FF; }
@font-face { font-family: "Readex"; font-weight: 700; font-display: swap; src: url(../fonts/readex-lat-700.woff2) format("woff2"); unicode-range: U+0000-00FF; }

/* ===== Athar design tokens v2 ===== */
:root {
  /* brand (fixed identity, do not theme) */
  --brand-900: #29504D;   /* dark green  */
  --brand-500: #00A05A;   /* light green */
  --brand-gray: #B2BEC4;  /* gray        */

  /* surfaces */
  --bg:            #F2F5F4;  /* page canvas, cool gray-green */
  --bg-tint:       #E7EEEC;  /* header band / sunken areas   */
  --surface:       #FFFFFF;  /* cards, sheets                */
  --surface-2:     #F7F9F8;  /* table head, inset rows        */
  --surface-hover: #EEF3F1;
  --overlay:       rgba(14, 32, 30, .48);

  /* text (all ≥4.5:1 on --bg and --surface) */
  --text:    #15302D;  /* 12.9:1 */
  --text-2:  #46595C;  /* secondary, 6.7:1 */
  --text-3:  #5E6E72;  /* hints, captions, 4.9:1 on bg */
  --text-on-brand: #FFFFFF;
  --text-on-accent: #04261A;
  --on-primary: #FFFFFF;     /* text on --primary */
  --hero-bg: #29504D; --hero-text: #FFFFFF; --hero-text-2: #B9D3CF; --hero-ring: #3FCB86; --hero-track: rgba(255,255,255,.14);
  --topbar-bg: rgba(242,245,244,.86); /* frosted bg-colored bar */

  /* lines */
  --border:        #DCE3E2;  /* card + field hairline */
  --border-strong: #B2BEC4;  /* brand gray: input hover, dividers in tables */
  --divider:       #E8EDEC;

  /* brand roles */
  --primary:        #29504D; /* primary buttons, active nav, headings accent */
  --primary-hover:  #213F3D;
  --primary-press:  #1A3331;
  --primary-soft:   #E4ECEB;
  --accent:         #00A05A; /* fills only: progress, rings, active indicator, success dots (3.4:1 => never small text on white) */
  --accent-text:    #007A45; /* green used AS TEXT/link on light (5.4:1) */
  --accent-soft:    #E3F4EB;

  /* semantic (text color / soft background / solid) */
  --ok:   #0E7A46; --ok-soft:   #E3F4EB; --ok-solid:   #00A05A;
  --warn: #8A5A00; --warn-soft: #FFF4DC; --warn-solid: #D99A1E;
  --bad:  #B3261E; --bad-soft:  #FDECEA; --bad-solid:  #C8372D;
  --info: #1F5F8B; --info-soft: #E6F0F8; --info-solid: #2F78AE;

  /* data series for rings/bars (4 metrics) */
  --series-1: #29504D; --series-2: #00A05A; --series-3: #2F78AE; --series-4: #D99A1E;
  --track: #E3E9E8;

  /* whatsapp action: light brand green, dark ink (4.8:1) - no WA logo, use message icon */
  --wa-bg: #00A05A; --wa-bg-hover: #008F50; --wa-text: #04261A;

  /* type */
  --font-body: "Plex Arabic", "IBM Plex Sans Arabic", Tahoma, system-ui, sans-serif;
  --font-display: "Readex", "Plex Arabic", Tahoma, sans-serif;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;

  --base: 16px;                 /* html font-size; 3 modes below */
  --fs-2xs: .75rem;   /* 12 badge text, chart ticks (never below this) */
  --fs-xs:  .8125rem; /* 13 captions, table head */
  --fs-sm:  .875rem;  /* 14 secondary, buttons-sm */
  --fs-md:  1rem;     /* 16 body, inputs, buttons */
  --fs-lg:  1.125rem; /* 18 card titles (h3) */
  --fs-xl:  1.3125rem;/* 21 section titles (h2) */
  --fs-2xl: 1.625rem; /* 26 page title (h1) */
  --fs-num: 2rem;     /* 32 stat tile numbers */
  --fs-hero:2.75rem;  /* 44 hero ring number */
  --lh-body: 1.7; --lh-tight: 1.35; --lh-num: 1.1;

  /* spacing (4px grid, px so it does not balloon in large mode) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;
  --gutter: 16px;            /* page side padding phone; 24px ≥768, 32px ≥1200 */
  --content-max: 1120px;

  /* radii (hierarchy, not one value) */
  --r-xs: 6px;    /* badges inside tables, kbd */
  --r-sm: 10px;   /* inputs, buttons, segmented */
  --r-md: 16px;   /* cards, tiles */
  --r-lg: 24px;   /* hero card, bottom sheet top corners, modal */
  --r-full: 999px;/* pills, rank chips, avatar */

  /* elevation (green-tinted, never pure black) */
  --e-0: none;
  --e-1: 0 1px 2px rgba(21,48,45,.05), 0 1px 1px rgba(21,48,45,.03);
  --e-2: 0 2px 4px -1px rgba(21,48,45,.06), 0 8px 20px -6px rgba(21,48,45,.10);
  --e-3: 0 24px 48px -12px rgba(21,48,45,.28), 0 4px 12px rgba(21,48,45,.08);
  --e-nav: 0 -1px 0 var(--border), 0 -8px 24px -12px rgba(21,48,45,.12);

  /* focus */
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px #00A05A;
  --focus-ring-danger: 0 0 0 2px var(--surface), 0 0 0 4px var(--bad-solid);

  /* sizes */
  --tap: 44px; --btn-h-sm: 36px; --btn-h-md: 44px; --btn-h-lg: 52px;
  --topbar-h: 56px; --bottomnav-h: 64px;

  /* motion */
  --dur-1: 120ms;  /* press, hover, toggles */
  --dur-2: 200ms;  /* small enter/exit, toast out */
  --dur-3: 280ms;  /* page, sheet, toast in */
  --dur-4: 420ms;  /* ring/progress fill */
  --ease-out:   cubic-bezier(.2, .8, .2, 1);    /* entrances */
  --ease-in:    cubic-bezier(.4, 0, 1, 1);      /* exits */
  --ease-inout: cubic-bezier(.65, 0, .35, 1);   /* shared-element / page */
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);/* only checkmarks + toggles */

  color-scheme: light;
}

/* ---------- font-size modes ---------- */
:root[data-size="medium"] { --base: 18px; --fs-num: 1.875rem; --fs-hero: 2.5rem; --fs-2xl: 1.5rem; }
:root[data-size="large"]  { --base: 20px; --fs-num: 1.75rem; --fs-hero: 2.25rem; --fs-2xl: 1.4rem; --fs-xl: 1.25rem;
                            --btn-h-md: 52px; --btn-h-sm: 44px; --lh-body: 1.65; }
/* In large mode: tables switch to the card-list at ≤ 900px instead of ≤ 640px; stat tiles go 1-up on phone. */

/* ---------- dark palette ---------- */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1817; --bg-tint: #122220; --surface: #152321; --surface-2: #1A2B29; --surface-hover: #1F3230;
  --overlay: rgba(0, 8, 7, .62);
  --text: #E8EFEE; --text-2: #B8C6C9; --text-3: #8FA3A7; --text-on-brand: #FFFFFF; --text-on-accent: #04261A; --on-primary: #04261A;
  --hero-bg: #1C3A37; --hero-text: #FFFFFF; --hero-text-2: #B9D3CF; --hero-ring: #3FCB86; --hero-track: rgba(255,255,255,.12);
  --topbar-bg: rgba(14,24,23,.86);
  --border: #243634; --border-strong: #3A4F4D; --divider: #1F302E;
  --primary: #3FCB86; --primary-hover: #55D594; --primary-press: #33B776; --primary-soft: #18352A;
  --accent: #3FCB86; --accent-text: #5FD69A; --accent-soft: #143127;
  --ok: #5FD69A; --ok-soft: #143127; --ok-solid: #3FCB86;
  --warn: #E9B65A; --warn-soft: #2A2112; --warn-solid: #E0A43A;
  --bad: #F2938A; --bad-soft: #2E1916; --bad-solid: #E5675C;
  --info: #8DC2EA; --info-soft: #14232F; --info-solid: #5AA3D8;
  --series-1: #8FC9C0; --series-2: #3FCB86; --series-3: #5AA3D8; --series-4: #E0A43A; --track: #223533;
  --wa-bg: #3FCB86; --wa-bg-hover: #55D594; --wa-text: #04261A;
  --e-1: 0 0 0 1px rgba(255,255,255,.02); --e-2: 0 8px 24px -8px rgba(0,0,0,.5);
  --e-3: 0 24px 56px -12px rgba(0,0,0,.7); --e-nav: 0 -1px 0 var(--border);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px #3FCB86;
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0E1817; --bg-tint: #122220; --surface: #152321; --surface-2: #1A2B29; --surface-hover: #1F3230;
  --overlay: rgba(0, 8, 7, .62);
  --text: #E8EFEE; --text-2: #B8C6C9; --text-3: #8FA3A7; --text-on-brand: #FFFFFF; --text-on-accent: #04261A; --on-primary: #04261A;
  --hero-bg: #1C3A37; --hero-text: #FFFFFF; --hero-text-2: #B9D3CF; --hero-ring: #3FCB86; --hero-track: rgba(255,255,255,.12);
  --topbar-bg: rgba(14,24,23,.86);
  --border: #243634; --border-strong: #3A4F4D; --divider: #1F302E;
  --primary: #3FCB86; --primary-hover: #55D594; --primary-press: #33B776; --primary-soft: #18352A;
  --accent: #3FCB86; --accent-text: #5FD69A; --accent-soft: #143127;
  --ok: #5FD69A; --ok-soft: #143127; --ok-solid: #3FCB86;
  --warn: #E9B65A; --warn-soft: #2A2112; --warn-solid: #E0A43A;
  --bad: #F2938A; --bad-soft: #2E1916; --bad-solid: #E5675C;
  --info: #8DC2EA; --info-soft: #14232F; --info-solid: #5AA3D8;
  --series-1: #8FC9C0; --series-2: #3FCB86; --series-3: #5AA3D8; --series-4: #E0A43A; --track: #223533;
  --wa-bg: #3FCB86; --wa-bg-hover: #55D594; --wa-text: #04261A;
  --e-1: 0 0 0 1px rgba(255,255,255,.02); --e-2: 0 8px 24px -8px rgba(0,0,0,.5);
  --e-3: 0 24px 56px -12px rgba(0,0,0,.7); --e-nav: 0 -1px 0 var(--border);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px #3FCB86;
  color-scheme: dark;
}
/* Dark-mode rule: primary button = mint fill (#3FCB86) with --text-on-accent ink (8.9:1).
   The brand dark green #29504D stays the identity color of the logo mark and hero card in BOTH themes (hero lifts to #1C3A37 in dark). */

/* ===== Athar components v2 (reference implementation for the spec) ===== */
* { box-sizing: border-box; }
html { font-size: var(--base); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: var(--fs-md);
  line-height: var(--lh-body); direction: rtl; -webkit-font-smoothing: antialiased; }
h1,h2,h3 { margin: 0; font-family: var(--font-display); line-height: var(--lh-tight); text-wrap: balance; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-xl); font-weight: 600; }
h3 { font-size: var(--fs-lg); font-weight: 600; }
p { margin: 0; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; } .icon.lg { width: 24px; height: 24px; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top); background: var(--topbar-bg); backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; transition: border-color var(--dur-2); }
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-in { height: var(--topbar-h); max-width: var(--content-max); margin: 0 auto; padding-inline: var(--gutter);
  display: flex; align-items: center; gap: var(--sp-2); }
.brand { display: flex; align-items: center; gap: var(--sp-2); text-decoration: none; color: var(--text);
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-900); display: grid; place-items: center; }
.top-actions { margin-inline-start: auto; display: flex; gap: var(--sp-1); }
.icon-btn { width: var(--tap); height: var(--tap); border-radius: var(--r-full); border: 0; background: transparent; color: var(--text-2);
  display: grid; place-items: center; cursor: pointer; position: relative; transition: background var(--dur-1); }
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn .badge-dot { position: absolute; top: 4px; inset-inline-start: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad-solid); color: #fff; font: 600 11px/18px var(--font-body); border: 2px solid var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--accent-text);
  font: 700 .875rem/34px var(--font-display); text-align: center; }

.bottomnav { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; background: var(--surface); box-shadow: var(--e-nav);
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.bottomnav a { height: var(--bottomnav-h); display: grid; justify-items: center; align-content: center; gap: 3px; text-decoration: none;
  color: var(--text-3); font-size: var(--fs-2xs); font-weight: 600; position: relative; }
.bottomnav a .pillbg { width: 56px; height: 30px; border-radius: var(--r-full); display: grid; place-items: center; transition: background var(--dur-2) var(--ease-out); }
.bottomnav a[aria-current="page"] { color: var(--text); }
.bottomnav a[aria-current="page"] .pillbg { background: var(--accent-soft); color: var(--accent-text); }
.bottomnav a.main .pillbg { background: var(--primary); color: var(--on-primary); width: 48px; height: 34px; }
main { max-width: var(--content-max); margin: 0 auto; padding: var(--sp-4) var(--gutter) calc(var(--bottomnav-h) + var(--sp-8) + env(safe-area-inset-bottom));
  display: grid; gap: var(--sp-4); }

/* ---------- page header ---------- */
.page-head { display: grid; gap: var(--sp-2); padding-block: var(--sp-2) var(--sp-1); }
.back { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600;
  text-decoration: none; min-height: 32px; justify-self: start; }
.page-head .sub { color: var(--text-2); font-size: var(--fs-sm); max-width: 60ch; }
.page-head .meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; color: var(--text-3); font-size: var(--fs-xs); }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); }
.context-bar { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; }

/* ---------- card / section ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--e-1); padding: var(--sp-5); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card.flush .card-head { padding: var(--sp-5) var(--sp-5) 0; }
.card-head .hint { color: var(--text-3); font-size: var(--fs-xs); }

/* hero summary (one per screen, the signature element) */
.hero { background: var(--hero-bg); color: var(--hero-text); border-radius: var(--r-lg); padding: var(--sp-6) var(--sp-5);
  display: grid; grid-template-columns: auto 1fr; gap: var(--sp-5); align-items: center; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset-inline-start: -40px; bottom: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(63,203,134,.18), transparent); pointer-events: none; }
.hero .label { color: var(--hero-text-2); font-size: var(--fs-sm); }
.hero .big { font-size: var(--fs-hero); line-height: var(--lh-num); font-weight: 700; }
.hero .foot { color: var(--hero-text-2); font-size: var(--fs-xs); margin-top: var(--sp-1); }

/* ring */
.ring { --p: 0; --size: 96px; --w: 3.2; /* stroke in viewBox units (viewBox 36) */ width: var(--size); height: var(--size); position: relative; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); } /* starts at 12 o’clock, fills clockwise (clock direction is not mirrored in RTL) */
.ring circle { fill: none; stroke-width: var(--w); }
.ring .trk { stroke: var(--track); } .ring .val { stroke: var(--ring-color, var(--accent)); stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p)); transition: stroke-dashoffset var(--dur-4) var(--ease-out); }
.hero .ring .trk { stroke: var(--hero-track); } .hero .ring .val { stroke: var(--hero-ring); }
.ring b { font-family: var(--font-display); font-size: 1.125rem; }

/* stat tile */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
@media (min-width: 768px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
:root[data-size="large"] .tiles { grid-template-columns: 1fr; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); display: grid; gap: var(--sp-2); box-shadow: var(--e-1); }
.tile .t-label { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; }
.tile .t-label i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); }
.tile .t-val { font-family: var(--font-display); font-size: var(--fs-num); line-height: var(--lh-num); font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .t-val small { font-size: .5em; color: var(--text-3); font-weight: 600; }
.tile .t-foot { color: var(--text-3); font-size: var(--fs-xs); }
.meter { height: 6px; border-radius: var(--r-full); background: var(--track); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transform-origin: right; }

/* ---------- list (phone alternative to table) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.li { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-1) var(--sp-3); align-items: center; padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--divider); min-height: 64px; }
.li .rank { width: 30px; height: 30px; border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2); display: grid; place-items: center;
  font: 600 var(--fs-xs)/1 var(--font-display); grid-row: span 2; }
.li .rank.top { background: var(--accent-soft); color: var(--accent-text); }
.li .name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .val { font: 700 var(--fs-md)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.li .meter { grid-column: 2 / 4; }
.li .sec { grid-column: 2 / 4; display: flex; gap: var(--sp-3); color: var(--text-3); font-size: var(--fs-xs); }

/* table (≥ 640px; ≥ 900px in large mode) */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.table th { position: sticky; top: var(--topbar-h); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600;
  text-align: start; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--divider); }
.table tr:hover td { background: var(--surface-hover); }
.table .n { text-align: center; }

/* ---------- buttons ---------- */
.btn { --h: var(--btn-h-md); height: var(--h); min-width: var(--h); padding-inline: var(--sp-5); border-radius: var(--r-sm); border: 1px solid transparent;
  font: 600 var(--fs-md)/1 var(--font-body); display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background var(--dur-1), border-color var(--dur-1), transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1); }
.btn:active:not([disabled]) { transform: scale(.97); }
.btn.sm { --h: var(--btn-h-sm); padding-inline: var(--sp-3); font-size: var(--fs-sm); gap: 6px; }
.btn.lg { --h: var(--btn-h-lg); padding-inline: var(--sp-6); font-size: var(--fs-lg); }
.btn.block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--e-1); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--accent-text); padding-inline: var(--sp-3); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-danger.solid { background: var(--bad-solid); color: #fff; border-color: transparent; }
.btn-wa { background: var(--wa-bg); color: var(--wa-text); }
.btn-wa:hover { background: var(--wa-bg-hover); }
.btn[disabled] { background: var(--surface-2); color: var(--text-3); border-color: var(--border); box-shadow: none; cursor: not-allowed; }
.btn[aria-busy="true"] { color: transparent; position: relative; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-primary) transparent var(--on-primary) var(--on-primary); animation: spin .8s linear infinite; }

/* ---------- pills / badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding-inline: 10px; border-radius: var(--r-full);
  font-size: var(--fs-2xs); font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.info { background: var(--info-soft); color: var(--info); }

/* ---------- fields ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > .lbl { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.field > .help { font-size: var(--fs-xs); color: var(--text-3); }
.field > .err { font-size: var(--fs-xs); color: var(--bad); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.input, .select { width: 100%; height: var(--btn-h-md); padding-inline: var(--sp-4); border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: var(--fs-md) var(--font-body); transition: border-color var(--dur-1), box-shadow var(--dur-1); }
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--bad-solid); background: var(--bad-soft); }
.select { appearance: none; padding-inline-end: var(--sp-4); padding-inline-start: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235E6E72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; }
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.seg button { height: 38px; padding-inline: var(--sp-3); border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font: 600 var(--fs-sm) var(--font-body); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--e-1); }

/* ---------- stepper (upload) ---------- */
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); counter-reset: s; }
.stepper li { display: grid; gap: var(--sp-2); font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); }
.stepper li::before { content: ""; height: 4px; border-radius: var(--r-full); background: var(--track); }
.stepper li.done::before, .stepper li.current::before { background: var(--accent); }
.stepper li.current { color: var(--text); }
.stepper li span::before { counter-increment: s; content: counter(s) " · "; font-family: var(--font-display); }

/* ---------- review row ---------- */
.rv { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--e-1);
  transition: border-color var(--dur-2), box-shadow var(--dur-2); }
.rv.flagged { border-color: var(--warn-solid); box-shadow: 0 0 0 1px var(--warn-solid); }
.rv.done { border-color: color-mix(in srgb, var(--ok-solid) 45%, var(--border)); }
.rv-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); }
.rv-head .idx { font: 600 var(--fs-xs) var(--font-display); color: var(--text-3); }
.rv-head .pill { margin-inline-start: auto; }
.rv-crop { background: #fff; border-block: 1px solid var(--divider); overflow-x: auto; }
.rv-crop img, .rv-crop .fake { display: block; height: 44px; min-width: 100%; }
.rv-body { padding: var(--sp-4); display: grid; gap: var(--sp-4); }
.rv-vals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-2); }
@media (min-width: 640px) { .rv-vals { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
:root[data-size="large"] .rv-vals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rv-vals .field > .lbl { font-size: var(--fs-2xs); color: var(--text-2); font-weight: 600; line-height: 1.3; min-height: 2.6em; display: flex; align-items: flex-end; }
.rv-vals .input { text-align: center; font: 700 var(--fs-lg) var(--font-display); padding-inline: var(--sp-1); font-variant-numeric: tabular-nums; }
.rv-vals .input.flag { border-color: var(--warn-solid); background: var(--warn-soft); }
.rv-vals .input.edited { border-color: var(--info-solid); background: var(--info-soft); }
.rv-vals .why { color: var(--warn); font-size: var(--fs-2xs); font-weight: 600; line-height: 1.35; }
.confirm { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); width: 100%; height: var(--btn-h-md); border-radius: var(--r-sm);
  border: 1.5px dashed var(--border-strong); background: transparent; color: var(--text-2); font: 600 var(--fs-md) var(--font-body); cursor: pointer;
  transition: background var(--dur-2), color var(--dur-2), border-color var(--dur-2); }
.confirm[aria-pressed="true"] { border-style: solid; border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.confirm[aria-pressed="true"] .icon { animation: pop var(--dur-3) var(--ease-spring); }

/* sticky action bar (screens with a commit action) */
.actionbar { position: sticky; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--sp-2)); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--e-2);
  padding: var(--sp-3); display: flex; align-items: center; gap: var(--sp-3); }
.actionbar .status { flex: 1; min-width: 0; font-size: var(--fs-xs); color: var(--text-2); display: grid; gap: 6px; }

/* ---------- notes / empty ---------- */
.note { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm); font-size: var(--fs-sm);
  background: var(--surface-2); color: var(--text); }
.note .icon { margin-top: 3px; }
.note.info { background: var(--info-soft); } .note.info .icon { color: var(--info); }
.note.warn { background: var(--warn-soft); } .note.warn .icon { color: var(--warn); }
.note.bad { background: var(--bad-soft); } .note.bad .icon { color: var(--bad); }
.note.ok { background: var(--ok-soft); } .note.ok .icon { color: var(--ok); }
.empty { display: grid; justify-items: center; text-align: center; gap: var(--sp-3); padding: var(--sp-10) var(--sp-5); }
.empty .em-ico { width: 56px; height: 56px; border-radius: var(--r-md); background: var(--primary-soft); color: var(--accent-text); display: grid; place-items: center; }
.empty h3 { font-size: var(--fs-lg); } .empty p { color: var(--text-2); font-size: var(--fs-sm); max-width: 36ch; }

/* ---------- toast ---------- */
.toast-region { position: fixed; inset-inline: var(--gutter); bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--sp-3)); z-index: 60;
  display: grid; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--sp-3); max-width: 480px; width: 100%; padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); background: #15302D; color: #F2F5F4; box-shadow: var(--e-3); font-weight: 600; font-size: var(--fs-sm);
  animation: toast-in var(--dur-3) var(--ease-out) both; }
.toast .icon { color: #3FCB86; } .toast.bad .icon { color: #F2938A; }
.toast .btn-ghost { color: #3FCB86; margin-inline-start: auto; height: 32px; }
.toast.leaving { animation: toast-out var(--dur-2) var(--ease-in) both; }

/* ---------- sheet / modal ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--overlay); display: grid; align-items: end; animation: fade var(--dur-3) var(--ease-out) both; }
.sheet { background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92dvh; overflow: auto; box-shadow: var(--e-3);
  padding: var(--sp-2) var(--sp-5) calc(var(--sp-5) + env(safe-area-inset-bottom)); animation: sheet-in var(--dur-3) var(--ease-out) both; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto var(--sp-3); }
.sheet-head { display: flex; align-items: center; gap: var(--sp-3); position: sticky; top: calc(-1 * var(--sp-2)); background: var(--surface); padding-block: var(--sp-2); }
.sheet-head h2 { flex: 1; font-size: var(--fs-lg); }
.sheet-foot { position: sticky; bottom: calc(-1 * var(--sp-5)); background: var(--surface); padding-top: var(--sp-3); display: flex; gap: var(--sp-2); }
@media (min-width: 768px) {
  .scrim { place-items: center; padding: var(--sp-6); }
  .sheet { width: min(600px, 100%); border-radius: var(--r-lg); padding: var(--sp-6); animation-name: modal-in; }
  .sheet .grab { display: none; }
}

/* ---------- motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes pop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.enter > * { animation: rise var(--dur-3) var(--ease-out) both; }
.enter > :nth-child(2) { animation-delay: 40ms; } .enter > :nth-child(3) { animation-delay: 80ms; }
.enter > :nth-child(4) { animation-delay: 120ms; } .enter > :nth-child(n+5) { animation-delay: 160ms; }

/* View Transitions (page change) */
::view-transition-old(root) { animation: vt-out var(--dur-2) var(--ease-in) both; }
::view-transition-new(root) { animation: vt-in var(--dur-3) var(--ease-out) both; }
.topbar { view-transition-name: topbar; } .bottomnav { view-transition-name: bottomnav; }
::view-transition-old(topbar), ::view-transition-new(topbar), ::view-transition-old(bottomnav), ::view-transition-new(bottomnav) { animation: none; }
@keyframes vt-out { to { opacity: 0; transform: translateX(12px); } }      /* RTL "forward" = content leaves to the right */
@keyframes vt-in  { from { opacity: 0; transform: translateX(-16px); } }
:root.back ::view-transition-old(root) { animation-name: vt-out-back; }
:root.back ::view-transition-new(root) { animation-name: vt-in-back; }
@keyframes vt-out-back { to { opacity: 0; transform: translateX(-12px); } }
@keyframes vt-in-back  { from { opacity: 0; transform: translateX(16px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .btn:active:not([disabled]) { transform: none; }
}

/* =====================================================================
   إضافات التطبيق (فوق المكونات)
   ===================================================================== */
a { color: var(--accent-text); }
.ltr { direction: ltr; text-align: right; unicode-bidi: plaintext; }
.muted { color: var(--text-2); } .hint { color: var(--text-3); font-size: var(--fs-xs); }
.row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: var(--sp-3); }
.grid2 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid3 { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* الحقول العامة: كل input/select/textarea بنفس شكل .input */
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-width: 0; height: var(--btn-h-md); padding-inline: var(--sp-4); border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: var(--fs-md) var(--font-body); transition: border-color var(--dur-1), box-shadow var(--dur-1); }
textarea { height: auto; min-height: 140px; padding-block: var(--sp-3); line-height: 1.8; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[aria-invalid="true"] { border-color: var(--bad-solid); background: var(--bad-soft); }
input[disabled], select[disabled] { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
select { appearance: none; padding-inline-start: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235E6E72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; }
input[type=date], input[type=datetime-local] { min-height: var(--btn-h-md); }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--brand-500); flex: none; margin: 2px 0 0; cursor: pointer; }
label.f { display: grid; gap: 6px; min-width: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
label.f small, .field .help { font-weight: 400; color: var(--text-3); font-size: var(--fs-xs); }
.check { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: var(--fs-sm); cursor: pointer; line-height: 1.6; }
.check.boxed { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.check.boxed.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn-solid) 40%, transparent); }
.check.boxed.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad-solid) 35%, transparent); }
.pw { position: relative; } .pw input { padding-inline-start: 48px; }
.pw .icon-btn { position: absolute; inset-inline-start: 2px; top: 0; height: var(--btn-h-md); width: 44px; border-radius: var(--r-sm); }
.inline-form { display: flex; gap: var(--sp-2); } .inline-form input { flex: 1; }

/* أزرار إضافية */
.btn .icon { margin: 0; }
.icon-btn.sm { width: 36px; height: 36px; }
.btn-wa .icon, .btn-primary .icon { color: inherit; }
.btn-link { background: none; border: 0; color: var(--accent-text); font: 600 var(--fs-sm) var(--font-body); cursor: pointer; padding: 6px 4px; text-decoration: none; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
.btn-link:hover { text-decoration: underline; }
.btn-secondary[aria-busy="true"]::after, .btn-danger[aria-busy="true"]::after, .btn-ghost[aria-busy="true"]::after { border-color: var(--text-2) transparent var(--text-2) var(--text-2); }
.btn[aria-busy="true"] .icon { visibility: hidden; }
.btn[disabled][aria-busy="true"] { background: inherit; }

/* الشريط العلوي على الحاسب: تبويبات بأيقونات */
.toptabs { display: none; }
@media (min-width: 900px) {
  .toptabs { display: flex; gap: 2px; margin-inline-start: var(--sp-6); height: 100%; align-items: stretch; }
  .toptabs a { display: flex; align-items: center; gap: var(--sp-2); padding-inline: var(--sp-3); color: var(--text-2); text-decoration: none;
    font-weight: 600; font-size: var(--fs-sm); position: relative; border-radius: 0; transition: color var(--dur-1); }
  .toptabs a:hover { color: var(--text); }
  .toptabs a[aria-current="page"] { color: var(--text); }
  .toptabs a[aria-current="page"]::after { content: ""; position: absolute; inset-inline: var(--sp-3); bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
  .bottomnav { display: none; }
  main { padding-bottom: var(--sp-16); }
  .actionbar { bottom: var(--sp-4); }
  .toast-region { bottom: var(--sp-6); }
}
.topbar .who { display: none; color: var(--text-3); font-size: var(--fs-xs); text-align: end; line-height: 1.3; }
@media (min-width: 1100px) { .topbar .who { display: block; } }
.bottomnav a .icon { width: 22px; height: 22px; }
.bottomnav a.main { color: var(--text); }
.bottomnav a.main .pillbg { box-shadow: var(--e-2); }
.icon-btn .badge-dot { line-height: 14px; }
.avatar-btn { padding: 0; }
body.loading::before { content: ""; position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 80;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: loadbar 1s linear infinite; }
@keyframes loadbar { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.boot { min-height: 70vh; display: grid; place-items: center; }

/* البطاقات */
.card-head h2 { font-size: var(--fs-lg); }
.card-head .actions { display: flex; gap: var(--sp-2); }
.card > .stack + .stack { margin-top: var(--sp-4); }
.card .hint-line { color: var(--text-3); font-size: var(--fs-xs); margin-top: var(--sp-3); }
.card-foot { border-top: 1px solid var(--divider); padding: var(--sp-3) var(--sp-5); display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.context-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
  display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); overflow: visible; box-shadow: var(--e-1); }
.context-bar label.f { font-size: var(--fs-xs); color: var(--text-2); }

/* البطل */
.hero .ring b { color: var(--hero-text); font-size: 1.05rem; }
.hero .big small { font-size: .45em; color: var(--hero-text-2); font-weight: 600; margin-inline-start: 4px; }
.hero .chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.hero .chip { background: rgba(255,255,255,.1); color: var(--hero-text); border-radius: var(--r-full); padding: 4px 12px; font-size: var(--fs-xs); font-weight: 600; text-decoration: none; }
.hero .hero-act { margin-top: var(--sp-4); }
.hero .btn-hero { background: #fff; color: #15302D; }
.hero .btn-hero:hover { background: #E3F4EB; }
.hero.plain { grid-template-columns: 1fr; }
.hero .hero-icon { width: 56px; height: 56px; border-radius: var(--r-md); background: rgba(255,255,255,.1); display: grid; place-items: center; color: var(--hero-ring); }
.hero .hero-icon .icon { width: 28px; height: 28px; }
@media (max-width: 380px) { .hero { grid-template-columns: 1fr; } }

/* بطاقة الإسناد (الرئيسية) */
.asg-card { display: grid; gap: var(--sp-3); }
.asg-card .asg-top { display: flex; align-items: flex-start; gap: var(--sp-3); }
.asg-card .asg-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.asg-card h3 { font-size: var(--fs-lg); }
.asg-card .asg-sub { color: var(--text-3); font-size: var(--fs-xs); }
.asg-card .asg-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.asg-card .pill { margin-inline-start: auto; }

/* القوائم والجداول: الجدول من 640px، والقائمة للجوال */
.v-table { display: none; }
@media (min-width: 640px) { .v-table { display: block; } .v-list { display: none; } }
:root[data-size="large"] .v-table { display: none; }
:root[data-size="large"] .v-list { display: block; }
@media (min-width: 900px) { :root[data-size="large"] .v-table { display: block; } :root[data-size="large"] .v-list { display: none; } }
.tw { overflow-x: auto; }
.table td.nm { font-weight: 600; min-width: 10em; }
.table tr:last-child td { border-bottom: 0; }
.table .bar-cell { min-width: 180px; }
.table .bar-cell .row { flex-wrap: nowrap; }
.table .bar-cell .meter { flex: 1; }
.table .rank { width: 30px; height: 30px; border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2); display: inline-grid; place-items: center; font: 600 var(--fs-xs)/1 var(--font-display); }
.table .rank.top { background: var(--accent-soft); color: var(--accent-text); }
.table th.n, .table td.n { text-align: center; }
.list > .li:first-child, .list > li:first-child > .li, .list > li:first-child > details > .li { border-top: 0; }
.card.flush .list { border-top: 1px solid var(--divider); }
.card.flush > .card-head + .tw, .card.flush > .card-head + .v-table, .card.flush > .card-head + .v-list { border-top: 1px solid var(--divider); }
details.li-d > summary { list-style: none; cursor: pointer; }
details.li-d > summary::-webkit-details-marker { display: none; }
details.li-d[open] > summary { background: var(--surface-2); }
.li .chev { grid-row: span 2; color: var(--text-3); transition: transform var(--dur-2); }
details.li-d[open] .chev { transform: rotate(-90deg); }
.li-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-4); padding: var(--sp-2) var(--sp-5) var(--sp-4); padding-inline-start: 62px; font-size: var(--fs-xs); color: var(--text-2); background: var(--surface-2); }
.li-more b { color: var(--text); font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.li.plain { grid-template-columns: 1fr auto; }
.li.plain .name { white-space: normal; }
.li .meta { grid-column: 1 / -1; color: var(--text-3); font-size: var(--fs-xs); display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.li .end { display: flex; gap: var(--sp-2); align-items: center; }
.li.link { text-decoration: none; color: inherit; }
.li.link:hover { background: var(--surface-hover); }
.li.unread { background: color-mix(in srgb, var(--info-soft) 60%, transparent); }
.li .dot-unread { width: 8px; height: 8px; border-radius: 50%; background: var(--info-solid); display: inline-block; }
.val-pair { font: 700 var(--fs-md)/1.2 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.val-pair .from { color: var(--text-3); font-weight: 600; }

/* الطلاب والرسائل */
.stu { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2) var(--sp-3); align-items: center; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--divider); }
.stu:first-child { border-top: 0; }
.stu .name { font-weight: 600; min-width: 0; }
.stu .phone { display: flex; gap: var(--sp-2); align-items: center; grid-column: 1 / 2; }
.stu .phone input { max-width: 190px; min-width: 11ch; height: 40px; font-variant-numeric: tabular-nums; }
.stu .send { grid-row: 1 / 3; grid-column: 2; }
@media (min-width: 640px) { .stu { grid-template-columns: minmax(0, 1fr) auto auto; } .stu .phone { grid-column: auto; } .stu .send { grid-row: auto; grid-column: auto; } }
.saved-tick { color: var(--ok); display: inline-flex; animation: pop var(--dur-3) var(--ease-spring); }
.msg { border-top: 1px solid var(--divider); padding: var(--sp-4) var(--sp-5); display: grid; gap: var(--sp-3); }
.msg:first-child { border-top: 0; }
.msg-top { display: flex; gap: var(--sp-2) var(--sp-3); align-items: flex-start; flex-wrap: wrap; }
.msg-top .who { flex: 1; min-width: 12em; }
.msg-top .who b { font-weight: 700; }
.msg-top .who .hint { display: block; }
.msgtext { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--divider); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); line-height: 1.85; }
.reply { border-inline-start: 3px solid var(--accent); background: var(--surface-2); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); display: grid; gap: var(--sp-2); }
.reply .reply-top { display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-3); }
.reply .reply-top b { color: var(--text); font-size: var(--fs-sm); }
details.disc > summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; min-height: 32px; }
details.disc[open] > summary { margin-bottom: var(--sp-2); }
.hist { border-inline-start: 3px solid var(--border); padding-inline-start: var(--sp-3); font-size: var(--fs-xs); color: var(--text-2); display: grid; gap: var(--sp-2); }
.wa-num { font: 700 var(--fs-lg)/1.2 var(--font-display); font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.phone-card { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.phone-card .icon { color: var(--accent-text); }

/* طريقة الحساب */
details.how { font-size: var(--fs-xs); color: var(--text-2); }
details.how summary { cursor: pointer; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; min-height: 32px; color: var(--text-2); }
details.how p { margin-top: var(--sp-1); max-width: 75ch; line-height: 1.8; }
.footnotes { display: grid; gap: var(--sp-1); padding-inline: var(--sp-1); }

/* الطلبات (مالك النظام) */
.req { display: grid; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--divider); }
.req:first-child { border-top: 0; }
.req .req-top { display: flex; gap: var(--sp-3); align-items: flex-start; }
.req .req-top .avatar { flex: none; }
.req .req-who { flex: 1; min-width: 0; }
.req .req-who b { display: block; }
.req .req-meta { display: flex; gap: var(--sp-1) var(--sp-3); flex-wrap: wrap; color: var(--text-3); font-size: var(--fs-xs); }
.req .req-act { display: grid; gap: var(--sp-2); grid-template-columns: 1fr auto auto; align-items: center; }
@media (max-width: 520px) { .req .req-act { grid-template-columns: 1fr 1fr; } .req .req-act input { grid-column: 1 / -1; } }
.acct { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--divider); }
.acct:first-child { border-top: 0; }
.acct .acct-top { display: flex; gap: var(--sp-3); align-items: center; }
.acct .acct-top > div { flex: 1; min-width: 0; }
.acct .acct-top .hint { display: block; overflow: hidden; text-overflow: ellipsis; }
.acct .acct-ctl { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: var(--sp-2); align-items: end; }
.chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip-s { display: inline-flex; align-items: center; height: 34px; padding-inline: var(--sp-3); border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: var(--fs-sm); }

/* شاشة الرفع */
.drop { display: grid; justify-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-8) var(--sp-5); border: 2px dashed var(--border-strong);
  border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; position: relative; transition: border-color var(--dur-2), background var(--dur-2); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { box-shadow: var(--focus-ring); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.drop .em-ico { width: 64px; height: 64px; border-radius: 18px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; box-shadow: var(--e-2); }
.drop .em-ico .icon { width: 28px; height: 28px; }
.drop b { font-size: var(--fs-lg); font-family: var(--font-display); }
.drop.disabled { opacity: .6; }
.progress { height: 8px; background: var(--track); border-radius: var(--r-full); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width var(--dur-3) var(--ease-out); }
.reading { display: grid; gap: var(--sp-3); padding: var(--sp-4) 0 0; }
.reading .row b { font-weight: 600; }
.review-tools { display: flex; gap: var(--sp-2) var(--sp-4); flex-wrap: wrap; align-items: center; justify-content: space-between; }
.review-tools .help { color: var(--text-3); font-size: var(--fs-xs); flex-basis: 100%; }
.rv-head .nm { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-who { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.rv-vals label.f { gap: 4px; }
.rv-vals .field .sub { color: var(--info); font-size: var(--fs-2xs); font-weight: 600; }
.rv-vals .input, .rv-vals input { text-align: center; font: 700 var(--fs-lg) var(--font-display); padding-inline: var(--sp-1); font-variant-numeric: tabular-nums; }
.rv-vals input.flag { border-color: var(--warn-solid); background: var(--warn-soft); }
.rv-vals input.edited { border-color: var(--info-solid); background: var(--info-soft); }
.rv-foot { padding: 0 var(--sp-4) var(--sp-4); }
.rv.done .rv-crop, .rv.done .rv-body { display: none; }
.rv.done .rv-foot { padding-top: 0; }
.rv-crop img { height: auto; max-height: 64px; width: 100%; object-fit: cover; object-position: right center; }
.rv-crop { background: #fff; }
.actionbar .status b { color: var(--text); font-weight: 700; font-size: var(--fs-sm); }
.actionbar .btn { flex: none; }
.unconfirmed-dot { color: var(--text-3); }

/* لوحة الحساب (الإعدادات) */
.acct-sheet { display: grid; gap: var(--sp-5); }
.me-card { display: flex; align-items: center; gap: var(--sp-3); }
.me-card .avatar { width: 48px; height: 48px; line-height: 48px; font-size: 1.1rem; }
.me-card .hint { display: block; }
.set-row { display: grid; gap: var(--sp-2); }
.set-row > span { font-weight: 600; font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--sp-2); }
.seg { width: 100%; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[data-v="normal"] { font-size: .85rem; } .seg button[data-v="medium"] { font-size: 1rem; } .seg button[data-v="large"] { font-size: 1.15rem; }

/* النوافذ */
.sheet { display: grid; gap: var(--sp-4); align-content: start; }
.sheet .sheet-body { display: grid; gap: var(--sp-4); }
.sheet .sheet-foot { flex-wrap: wrap; z-index: 1; }
.sheet .sheet-foot .btn { flex: 1; }
.scrim.leaving { animation: fade var(--dur-2) var(--ease-in) reverse both; }
.scrim.leaving .sheet { animation: sheet-out var(--dur-2) var(--ease-in) both; }
@keyframes sheet-out { to { transform: translateY(100%); } }
@media (min-width: 768px) { .scrim.leaving .sheet { animation: modal-out var(--dur-2) var(--ease-in) both; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
.confirm-sheet .sheet-head .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); flex: none; }
.confirm-sheet.danger .sheet-head .ico { background: var(--bad-soft); color: var(--bad); }
.confirm-sheet p { color: var(--text-2); }
body.modal-open { overflow: hidden; }

/* الدخول والتسجيل */
.auth { min-height: 100dvh; display: grid; align-content: start; justify-items: center; position: relative; padding: 0 var(--gutter) var(--sp-10); }
.auth-band { position: absolute; inset: 0 0 auto; height: 260px; background: var(--hero-bg); border-radius: 0 0 var(--r-lg) var(--r-lg); overflow: hidden; }
.auth-band::after { content: ""; position: absolute; inset-inline-start: -60px; bottom: -120px; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(closest-side, rgba(63,203,134,.25), transparent); }
.auth-band::before { content: ""; position: absolute; inset-inline-end: -40px; top: -80px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,255,255,.08), transparent); }
.auth-top { position: relative; z-index: 1; width: min(480px, 100%); display: flex; justify-content: flex-end; padding-top: calc(var(--sp-3) + env(safe-area-inset-top)); }
.auth-top .icon-btn { color: #fff; } .auth-top .icon-btn:hover { background: rgba(255,255,255,.12); }
.auth-brand { position: relative; z-index: 1; color: #fff; display: grid; justify-items: center; gap: var(--sp-2); margin: var(--sp-2) 0 var(--sp-6); text-align: center; }
.auth-brand .mark { width: 64px; height: 64px; border-radius: 18px; background: rgba(255,255,255,.1); display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.auth-brand h1 { font-size: 2rem; color: #fff; }
.auth-brand p { color: #B9D3CF; font-size: var(--fs-sm); }
.auth-card { position: relative; z-index: 1; width: min(480px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--e-3); padding: var(--sp-6) var(--sp-5); }
.auth-card form, .auth-card > div { display: grid; gap: var(--sp-4); }
.auth-card h2 { font-size: var(--fs-xl); }
.auth-card .sub { color: var(--text-2); font-size: var(--fs-sm); }
.auth-links { display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.auth-foot { position: relative; z-index: 1; margin-top: var(--sp-5); color: var(--text-3); font-size: var(--fs-xs); text-align: center; }

/* حالات فارغة داخل البطاقات */
.card .empty { padding: var(--sp-8) var(--sp-4); }
.empty .btn { margin-top: var(--sp-1); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--track); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; display: inline-block; flex: none; }
.note b { font-weight: 700; }
.note a { font-weight: 600; }
.note > div { flex: 1; min-width: 0; }
.note .btn { margin-top: var(--sp-2); }

/* ظهور الحلقات والمقاييس (البطل والبطاقات فقط) */
.hero .ring .val, .tile .meter i { animation: fill-in var(--dur-4) var(--ease-out) both; }
.hero .ring .val { animation-name: ring-in; }
@keyframes ring-in { from { stroke-dashoffset: 100; } }
@keyframes fill-in { from { transform: scaleX(0); } }
.tile .meter i { transform-origin: right; }

/* الطباعة */
@media print {
  .topbar, .bottomnav, .noprint, .btn, .toast-region, .actionbar, .context-bar, .page-actions, .back { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .card, .tile { box-shadow: none; break-inside: avoid; }
  .hero { background: #fff !important; color: #000; border: 1px solid #bbb; }
  .hero .label, .hero .foot { color: #333; }
  .v-table { display: block !important; } .v-list { display: none !important; }
  .table th { position: static; }
}
label.f > .pill, label.field > .pill { justify-self: start; }
.sheet .sheet-foot .btn { white-space: normal; height: auto; min-height: var(--h); padding-block: var(--sp-2); line-height: 1.4; text-align: center; }
