/* عدسة — واجهة العميل: يفتحها صاحب الفروع على جواله صباحاً. وضوحٌ قبل الكثافة، والجوال أولاً.
   الألوان من دليل الهوية وحده (#4d67b0 · #5dbf8f · #414042). والخط IBM Plex Sans Arabic مستضافٌ
   ذاتياً بترخيص OFL — لا مورد خارجي، وسياسة أمن المحتوى تمنعه أصلاً. ولا نمط مضمَّن: كل شكلٍ صنفٌ هنا. */

@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/fonts/plex-arabic-400.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/fonts/plex-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/assets/fonts/plex-arabic-500.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/assets/fonts/plex-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/assets/fonts/plex-arabic-600.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/assets/fonts/plex-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }

:root {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f1f3f8; --border: #e3e7ef; --border-strong: #c9d0dc;
  --text: #1f2330; --muted: #5d6576;
  --accent: #4d67b0; --accent-hover: #3f579a; --accent-ink: #ffffff; --accent-soft: #eaeef9;
  --brand-green: #5dbf8f; --ok: #1f7a50; --ok-soft: #e4f5ec; --warn: #8a5d00; --warn-soft: #fcf1d8;
  --danger: #b3261e; --danger-soft: #fce8e6; --focus: #4d67b0;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 2px 8px rgba(20, 30, 60, .04);
  --shadow-hover: 0 6px 22px rgba(30, 45, 90, .10); --shadow-lg: 0 18px 50px rgba(15, 25, 50, .22);
  --side-w: 250px; --rail-w: 78px; --side-bg: #111c33; --side-bg-2: #172443; --side-text: #d5dcec; --side-muted: #8793ae;
  --side-hover: rgba(255, 255, 255, .07); --side-active: #4d67b0; --gap: .75rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d121a; --surface: #151c27; --surface-2: #1b2431; --border: #263142; --border-strong: #354257;
    --text: #e7eaf0; --muted: #9ca6b5; --accent: #93a6e2; --accent-hover: #aebcea; --accent-ink: #0d121a; --accent-soft: #1e2944;
    --ok: #72d1a0; --ok-soft: #152e24; --warn: #e6ba55; --warn-soft: #30270f; --danger: #f28b82; --danger-soft: #3a1c1a; --focus: #93a6e2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35); --shadow-hover: 0 6px 22px rgba(0, 0, 0, .45); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
    --side-bg: #0f1829; --side-bg-2: #15213a; color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Plex Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; line-height: 1.6; font-weight: 400; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.06rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num, td.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86em; direction: ltr; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---------- الإقلاع ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-msg { color: var(--muted); padding: 2rem; text-align: center; }
.boot-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem 1.8rem; max-width: 30rem; box-shadow: var(--shadow); margin: 1rem; }
.boot-card h1 { margin-bottom: .6rem; }

/* ---------- الهيكل ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .22s ease; }
.shell.rail { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.content { min-width: 0; display: flex; flex-direction: column; }
.main { min-width: 0; width: 100%; max-width: 1200px; margin-inline: auto; padding: 1.4rem 1.6rem 3rem; outline: none; }
.side { position: sticky; top: var(--gap); height: calc(100vh - 2 * var(--gap)); margin: var(--gap); margin-inline-end: 0;
  background: linear-gradient(180deg, var(--side-bg-2), var(--side-bg) 42%); color: var(--side-text); border-radius: 20px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; z-index: 40; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem .9rem; min-height: 72px; }
.logo { width: 38px; height: 38px; border-radius: 11px; flex: none; box-shadow: 0 4px 14px rgba(77, 103, 176, .45); }
.logo.sm { width: 28px; height: 28px; border-radius: 8px; box-shadow: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text b { font-size: 1.12rem; color: #fff; font-weight: 600; }
.brand-text span { font-size: .78rem; color: var(--side-muted); white-space: nowrap; }
.brand .env { margin-inline-start: auto; font-size: .7rem; font-weight: 500; color: #1b1400; background: #e6ba55; padding: .05rem .5rem; border-radius: 99px; white-space: nowrap; }
.side .drawer-close { display: none; }
.nav { flex: 1; overflow-y: auto; padding: .3rem .7rem 1rem; scrollbar-width: thin; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-group + .nav-group { margin-top: 1rem; }
.nav-title { font-size: .72rem; font-weight: 500; color: var(--side-muted); padding: 0 .75rem .35rem; white-space: nowrap; }
.nav a { position: relative; display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 11px; color: var(--side-text); font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
.nav a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: var(--side-active); color: #fff; box-shadow: 0 6px 18px rgba(77, 103, 176, .45); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -.7rem; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--brand-green); }
.nav .label { overflow: hidden; text-overflow: ellipsis; }
.count { margin-inline-start: auto; min-width: 1.35rem; height: 1.35rem; padding: 0 .38rem; border-radius: 99px; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 600; background: #e6ba55; color: #1b1400; font-variant-numeric: tabular-nums; }
.count.danger { background: #f28b82; color: #2a0806; }
.side-foot { padding: .7rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: inherit; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--side-hover); }
.side .icon-btn { color: var(--side-muted); }
.side-toggle { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .75rem; border: 0; border-radius: 11px; background: transparent; color: var(--side-muted); font: inherit; font-size: .85rem; cursor: pointer; }
.side-toggle:hover { background: var(--side-hover); color: #fff; }
.side-toggle .ico { transition: transform .22s ease; }
.shell.rail .brand { justify-content: center; padding-inline: 0; }
.shell.rail .brand-text, .shell.rail .brand .env, .shell.rail .nav .label, .shell.rail .side-toggle .label { display: none; }
.shell.rail .nav { padding-inline: .6rem; }
.shell.rail .nav-title { height: 1px; padding: 0; margin: .2rem .9rem .6rem; background: rgba(255, 255, 255, .1); color: transparent; overflow: hidden; }
.shell.rail .nav a { justify-content: center; padding: .6rem 0; }
.shell.rail .count { position: absolute; top: 3px; inset-inline-end: 6px; min-width: .6rem; height: .6rem; padding: 0; font-size: 0; }
.shell.rail .side-toggle { justify-content: center; padding-inline: 0; }
.shell.rail .side-toggle .ico { transform: scaleX(-1); }

/* ---------- الشريط العلوي ---------- */
.topbar { display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 25; padding: .7rem 1.6rem; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .menu-btn, .topbar .brand-sm { display: none; }
.topbar .icon-btn { color: var(--text); position: relative; }
.topbar .icon-btn:hover { background: var(--surface-2); }
.topbar .grow { flex: 1; min-width: 0; }
.topbar .tenant { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anchor { position: relative; }
.pop { position: absolute; top: calc(100% + .4rem); inset-inline-start: 0; min-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: .35rem; z-index: 50; max-height: 70vh; overflow-y: auto; }
.pop.end { inset-inline-start: auto; inset-inline-end: 0; min-width: 17rem; }
.pop a, .pop button.item { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .5rem .7rem; border-radius: 10px; color: var(--text); background: none; border: 0; font: inherit; text-align: start; cursor: pointer; }
.pop a:hover, .pop button.item:hover { background: var(--accent-soft); text-decoration: none; }
.pop .empty { padding: 1rem; }
.dot-count { position: absolute; top: 1px; inset-inline-end: 1px; min-width: 1.1rem; height: 1.1rem; padding: 0 .3rem; border-radius: 99px; font-size: .68rem; font-weight: 600; display: grid; place-items: center; background: #e6ba55; color: #1b1400; }
.dot-count.danger { background: var(--danger); color: #fff; }
.me-btn { display: flex; align-items: center; gap: .45rem; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; padding: .2rem .45rem; border-radius: 99px; }
.me-btn:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 600; background: linear-gradient(135deg, var(--brand-green), #3f9f72); color: #06261a; font-size: .9rem; }
.me-btn .ico { width: 16px; height: 16px; color: var(--muted); }
.me-card { padding: .6rem .7rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; display: grid; gap: .2rem; }
.scrim { display: none; }

@media (max-width: 900px) {
  .shell, .shell.rail { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: .5rem; bottom: .5rem; height: auto; margin: 0; inset-inline-start: .5rem; width: min(290px, 86vw); transform: translateX(calc(100% + 1rem)); transition: transform .24s ease; }
  [dir="ltr"] .side { transform: translateX(calc(-100% - 1rem)); }
  .shell.drawer-open .side { transform: none; }
  .shell.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 16, 30, .45); z-index: 30; }
  .side .drawer-close { display: inline-grid; margin-inline-start: auto; }
  .brand .env { margin-inline-start: 0; }
  .shell.rail .brand-text, .shell.rail .brand .env, .shell.rail .nav .label { display: revert; }
  .shell.rail .nav a { justify-content: flex-start; padding: .55rem .75rem; }
  .shell.rail .nav-title { height: auto; margin: 0; padding: 0 .75rem .35rem; background: none; color: var(--side-muted); }
  .shell.rail .count { position: static; min-width: 1.35rem; height: 1.35rem; padding: 0 .38rem; font-size: .72rem; }
  .side-toggle { display: none; }
  .topbar { padding: .55rem .8rem; gap: .4rem; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar .brand-sm { display: block; }
  .me-btn .me-name, .me-btn .ico { display: none; }
  .main { padding: 1rem .9rem 5rem; }
}
@media (prefers-reduced-motion: reduce) { .shell, .side, .side-toggle .ico, .nav a, .stat { transition: none !important; } }

.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 12rem; }
.page-head .sub { color: var(--muted); margin-top: .2rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { font-size: .87rem; color: var(--muted); margin-bottom: .35rem; }
.crumbs a { color: var(--muted); }

/* ---------- الرئيسية ---------- */
.hero { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap; padding: 1.4rem 1.5rem; margin-bottom: 1.3rem; border-radius: 20px; color: #fff;
  background: linear-gradient(120deg, #3f579a 0%, #4d67b0 55%, #4f8fa3 100%); box-shadow: 0 10px 30px rgba(63, 87, 154, .28); }
.hero::after { content: ""; position: absolute; inset-inline-end: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(93, 191, 143, .45), transparent 70%); pointer-events: none; }
.hero h1 { font-size: 1.6rem; }
.hero p { margin: .25rem 0 0; color: rgba(255, 255, 255, .85); }
.hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .28); color: #fff; }
.hero .btn:hover { background: rgba(255, 255, 255, .22); }
.hero .btn.primary { background: #fff; color: #2f4686; border-color: #fff; }
.section-title { font-size: .95rem; color: var(--muted); font-weight: 500; margin: 0 .1rem .6rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.3rem; }
.stat { position: relative; display: flex; flex-direction: column; gap: .15rem; padding: .95rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
a.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.stat-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.stat-value { font-size: 1.65rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-value small { font-size: .95rem; font-weight: 500; color: var(--muted); }
.stat-label { color: var(--text); font-weight: 500; font-size: .92rem; }
.stat-hint { color: var(--muted); font-size: .8rem; }
.stat.info .stat-ico { background: var(--accent-soft); color: var(--accent); }
.stat.ok .stat-ico { background: var(--ok-soft); color: var(--ok); }
.stat.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.stat.warn .stat-ico { background: var(--warn-soft); color: var(--warn); }
.stat.warn .stat-value { color: var(--warn); }
.stat.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.stat.danger .stat-ico { background: var(--danger-soft); color: var(--danger); }
.stat.danger .stat-value { color: var(--danger); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .8rem; }
.steps li { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem; border-radius: 12px; background: var(--surface-2); }
.step-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 600; font-size: .85rem; background: var(--accent); color: var(--accent-ink); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center; padding: 1.6rem 1rem; color: var(--muted); }
.empty-state .ico { width: 34px; height: 34px; padding: 7px; box-sizing: content-box; border-radius: 50%; background: var(--surface-2); color: var(--accent); margin-bottom: .2rem; }
.empty-state b { color: var(--text); font-weight: 500; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-green); margin-top: .5rem; flex: none; box-shadow: 0 0 0 4px var(--ok-soft); }
.feed-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.feed-dot.bad { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.feed-meta { font-size: .8rem; color: var(--muted); }

/* ---------- البطاقات والشبكات ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; overflow: hidden; }
.card > header { display: flex; align-items: center; gap: .6rem; padding: .9rem 1.1rem .5rem; flex-wrap: wrap; }
.card > header h2 { flex: 1; }
.card > header .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: .9rem; }
.card .body { padding: .6rem 1.1rem 1.1rem; }
.card > header + .body.flush { border-top: 1px solid var(--border); margin-top: .4rem; }
.card .body.flush { padding: 0; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.two > :only-child { grid-column: 1 / -1; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 1rem; }
@media (max-width: 1000px) { .grid.two { grid-template-columns: 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
dl.kv { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: .4rem 1.1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { dl.kv { grid-template-columns: 1fr; gap: .1rem; } dl.kv dd { margin-bottom: .5rem; } }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th { text-align: start; font-weight: 500; color: var(--muted); font-size: .82rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.data td { padding: .6rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--accent-soft); }
table.data td.num, table.data th.num { text-align: end; }
.empty { padding: 2.2rem 1rem; text-align: center; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 500; padding: .1rem .6rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); vertical-align: middle; margin-inline-end: .35rem; }
.dot.on { background: var(--brand-green); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: var(--danger); }

/* ---------- الأزرار ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 500; font-size: .92rem; line-height: 1.4; padding: .5rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; min-height: 40px; }
.btn .ico { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { padding: .22rem .65rem; font-size: .84rem; min-height: 32px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }

/* ---------- النماذج ---------- */
form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field > span.lbl { font-size: .87rem; font-weight: 500; }
.field > span.lbl .req { color: var(--danger); margin-inline-start: .15rem; }
.field .hint { font-size: .8rem; color: var(--muted); }
.field .err { font-size: .82rem; color: var(--danger); }
input, select, textarea { font: inherit; font-size: .94rem; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .5rem .65rem; width: 100%; min-width: 0; min-height: 40px; }
textarea { resize: vertical; min-height: 4.2rem; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type="time"], input[type="date"], input[type="datetime-local"] { direction: ltr; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 35%, transparent); outline-offset: 0; border-color: var(--focus); }
.invalid input, .invalid select, .invalid textarea { border-color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: .93rem; cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.toolbar .field { min-width: 9rem; flex: 1; }
.alert { border-radius: var(--radius-sm); padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert.info { background: var(--accent-soft); color: var(--text); }
.alert.warn { background: var(--warn-soft); color: var(--text); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.alert.danger { background: var(--danger-soft); color: var(--text); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.alert.ok { background: var(--ok-soft); color: var(--text); }
.alert h3 { margin-bottom: .2rem; }
.alert ul { margin: .3rem 0 0; padding-inline-start: 1.2rem; }
.trace { font-size: .75rem; color: var(--muted); margin-top: .3rem; }
.toasts { position: fixed; inset-block-end: 1rem; inset-inline-start: 50%; transform: translateX(50%); display: flex; flex-direction: column; gap: .5rem; z-index: 60; pointer-events: none; }
[dir="ltr"] .toasts { transform: translateX(-50%); }
.toast { background: var(--side-bg); color: #fff; padding: .6rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .92rem; }
.toast.danger { background: var(--danger); color: #fff; }

/* ---------- الحوار ---------- */
dialog { border: 1px solid var(--border); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); }
dialog::backdrop { background: rgba(10, 16, 30, .5); backdrop-filter: blur(2px); }
dialog > form > header { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .6rem; }
dialog > form > header h2 { flex: 1; }
dialog .dlg-body { padding: 1rem 1.2rem; overflow-y: auto; max-height: calc(100vh - 10rem); }
dialog > form > footer { padding: .85rem 1.2rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); }

/* ---------- التبويبات والمواعيد والرمز ---------- */
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: thin; }
.tabs a { display: inline-flex; align-items: center; gap: .35rem; padding: .6rem .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.hours { display: grid; gap: .4rem; }
.hours-row { display: grid; grid-template-columns: 6.5rem 1fr 1fr 1fr; gap: .5rem; align-items: center; padding: .4rem .6rem; border-radius: 10px; background: var(--surface-2); }
.hours-row.off input[type="time"] { opacity: .35; }
.hours-row .day { font-weight: 500; }
.hours-tpl { display: grid; grid-template-columns: 1fr 1fr auto; gap: .6rem; align-items: end; padding: .8rem; border: 1px dashed var(--border-strong); border-radius: 12px; margin-bottom: .8rem; }
@media (max-width: 600px) { .hours-row { grid-template-columns: 5rem 1fr 1fr; } .hours-row .grace { display: none; } .hours-tpl { grid-template-columns: 1fr; } }
.code-big { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.6rem; letter-spacing: .08em; direction: ltr; unicode-bidi: isolate; text-align: center; padding: .9rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border-strong); user-select: all; }
.meta-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .9rem; border-inline-start: 2px solid var(--border); margin-inline-start: .45rem; padding-inline-start: 1.1rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -7px; top: .45rem; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li:last-child { border-color: transparent; padding-bottom: 0; }
.timeline .when { font-size: .82rem; color: var(--muted); }

/* ---------- هيكل التحميل ---------- */
.skeleton { height: 1rem; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 6px; margin: .5rem 0; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-page { animation: sk-in .2s ease-out .15s both; }
@keyframes sk-in { from { opacity: 0; } to { opacity: 1; } }
.sk-head { margin-bottom: 1.2rem; }
.skeleton.sk-title { height: 1.7rem; border-radius: 8px; }
.skeleton.sk-num { height: 1.9rem; margin-top: .6rem; }
.skeleton.sk-thin { height: .7rem; }
.skeleton.sk-field { height: 2.3rem; border-radius: 10px; margin: 0; }
.sk-w10 { width: 10%; } .sk-w15 { width: 15%; } .sk-w25 { width: 25%; } .sk-w30 { width: 30%; } .sk-w40 { width: 40%; } .sk-w50 { width: 50%; } .sk-w60 { width: 60%; } .sk-w70 { width: 70%; }
.sk-row { display: flex; gap: 1.4rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: 0; }
.sk-row > .skeleton { margin: 0; flex: none; }
.sk-toolbar { display: flex; gap: .6rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.sk-toolbar > .skeleton { flex: none; }
.sk-fieldrow { display: grid; grid-template-columns: minmax(6rem, 11rem) 1fr; gap: 1rem; align-items: center; padding: .45rem 0; }
@media (max-width: 640px) { .sk-fieldrow { grid-template-columns: 1fr; gap: .3rem; } .sk-row > .skeleton:nth-child(n+3) { display: none; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .sk-page { animation: none; } }

@media print {
  .side, .topbar, .scrim, .hero-actions, .page-head .actions, .card > header .actions, .form-actions, .toolbar { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
  .card, .stat { box-shadow: none; border-color: #bbb; }
  .hero { background: none; color: #000; box-shadow: none; border: 1px solid #bbb; }
  .hero p { color: #000; }
}
