
:root {
  --bg: #f6f5f2; --bg-tint: #f1f0fb; --card: #ffffff; --text: #1f1d1a; --muted: #6f6a62; --line: #ece8e1; --line-strong: #ddd8cf;
  --accent: #4b5bd6; --accent-dark: #3f4ec4; --accent-soft: #eef0fd; --accent-line: #d6dafb;
  --good: #1f7a4d; --good-soft: #e6f5ed; --bad: #b3372f; --bad-soft: #fcecea; --warn: #8a5a00; --warn-soft: #fcf3df;
  --info: #2a6fc0; --info-soft: #e8f1fc; --neutral-soft: #f1efea; --row: #faf9f6; --grid: #efece6;
  --radius: 22px; --r-md: 16px; --r-sm: 12px;
  --shadow: 0 1px 2px rgba(31, 29, 26, .04), 0 12px 32px -16px rgba(31, 29, 26, .12);
  --shadow-hover: 0 2px 4px rgba(31, 29, 26, .05), 0 20px 40px -18px rgba(75, 91, 214, .28);
  --grad: linear-gradient(135deg, #4b5bd6 0%, #6a76e4 50%, #9aa3f1 100%);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; line-height: 1.6;
  background: radial-gradient(1100px 480px at 85% -10%, var(--bg-tint), transparent 60%) no-repeat, var(--bg); min-height: 100vh; }
a { color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .panel, .kpi, .card { animation: rise .45s both; }
  .kpis > :nth-child(2), .cards > :nth-child(2) { animation-delay: .04s; } .kpis > :nth-child(3), .cards > :nth-child(3) { animation-delay: .08s; }
  .kpis > :nth-child(4), .cards > :nth-child(4) { animation-delay: .12s; } .kpis > :nth-child(5) { animation-delay: .16s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
/* جاري التنفيذ: شريط متحرك أعلى الصفحة، والزر المضغوط يدور ولا يُضغط مرتين */
#busy-bar { position: fixed; top: 0; right: 0; left: 0; height: 3px; z-index: 1000; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .2s; }
#busy-bar.on { opacity: 1; }
#busy-bar::before { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--grad); border-radius: 3px; animation: busy-slide 1.1s ease-in-out infinite; }
@keyframes busy-slide { from { right: -40%; } to { right: 100%; } }
@keyframes busy-spin { to { transform: rotate(360deg); } }
button.is-busy, .btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
button.is-busy > *, .btn.is-busy > * { visibility: hidden; }
button.is-busy::after, .btn.is-busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(127, 127, 127, .35); border-top-color: var(--accent); animation: busy-spin .7s linear infinite; }
button.primary.is-busy::after, button.danger.is-busy::after { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }
form.is-busy .switch { opacity: .6; pointer-events: none; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 26px 32px 64px; }
body.public .wrap { padding-top: 24px; }
/* الهيكل: قائمة جانبية فاتحة على اليمين، والمحتوى بجانبها */
body.app { display: grid; grid-template-columns: 96px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; background: rgba(255, 255, 255, .85); backdrop-filter: blur(12px); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: 18px 8px; gap: 6px; }
.rail-logo { width: 46px; height: 46px; border-radius: 15px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px;
  text-decoration: none; margin-bottom: 18px; box-shadow: 0 10px 20px -10px rgba(75, 91, 214, .7); transition: transform .2s; }
.rail-logo:hover { transform: scale(1.05); }
.rail nav { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.rail nav a, .rail-foot a, .rail-out { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 10px 4px; border-radius: 16px;
  color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.3; text-align: center; border: 0; background: none; min-height: 0; box-shadow: none; transition: background .2s, color .2s; }
.rail nav a .icon, .rail-out .icon { width: 22px; height: 22px; }
.rail nav a:hover, .rail-foot a:hover, .rail-out:hover { background: var(--bg); color: var(--text); transform: none; box-shadow: none; }
.rail nav a.on, .rail-foot a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; width: 100%; }
.rail-foot form { margin: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 14px; font-weight: 600; flex: none; }
/* شريط الموبايل: عائم في الأسفل مثل التطبيقات، و«المزيد» يفتح بقية الصفحات والحساب */
.topline { display: flex; justify-content: flex-end; margin: -10px 0 6px; }
.tabbar { display: none; }
@media (max-width: 760px) {
  body.app { grid-template-columns: minmax(0, 1fr); padding-bottom: 96px; }
  .rail, .topline { display: none; }
  .wrap { padding: 18px 16px 32px; }
  .tabbar { display: flex; position: fixed; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; right: 12px; z-index: 60; background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 22px; padding: 6px; box-shadow: 0 16px 40px -16px rgba(31, 29, 26, .3); }
  .tabbar > a, .tabbar summary { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; border-radius: 16px;
    font-size: 13px; color: var(--muted); text-decoration: none; cursor: pointer; list-style: none; }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar .icon { width: 22px; height: 22px; }
  .tabbar > a.on, .tabbar details.on summary, .tabbar details[open] summary { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .tabbar details { flex: 1; display: flex; }
  .tabbar details summary { width: 100%; }
  .more-sheet { position: absolute; left: 0; right: 0; bottom: calc(100% + 10px); background: var(--card); border: 1px solid var(--line);
    border-radius: 20px; box-shadow: 0 20px 50px -16px rgba(31, 29, 26, .35); padding: 8px; animation: rise .2s both; }
  .more-sheet .usermenu-head { padding: 10px 12px 12px; }
  .more-sheet a, .more-sheet button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 14px; border: 0; background: none;
    color: var(--text); text-decoration: none; font-size: 15px; min-height: 0; justify-content: flex-start; box-shadow: none; }
  .more-sheet a.on { background: var(--accent-soft); color: var(--accent); }
  .more-sheet form { margin: 0; }
}
/* رأس الصفحة */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title { min-width: 0; }
.page-title h1 { font-size: 30px; font-weight: 700; margin: 0; letter-spacing: -.3px; line-height: 1.3; }
.page-title p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-end; min-width: 0; max-width: 100%; }
@media (max-width: 760px) {
  .page-head { flex-direction: column; align-items: stretch; margin-bottom: 18px; }
  .page-title h1 { font-size: 26px; }
  .page-actions { justify-content: flex-start; }
  .page-actions .seg-inline { max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .page-actions .seg-inline::-webkit-scrollbar { display: none; }
}
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: inline-flex; align-items: center; gap: 10px; padding: 5px 12px 5px 6px; border-radius: 999px; cursor: pointer; transition: background .2s, box-shadow .2s; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: var(--card); box-shadow: var(--shadow); }
.usermenu .caret, .caret { width: 7px; height: 7px; border-left: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg) translateY(-2px); }
.usermenu-pop { position: absolute; left: 0; top: calc(100% + 6px); min-width: 250px; background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 18px 44px -14px rgba(31, 29, 26, .22); padding: 8px; z-index: 70; animation: rise .18s both; }
.usermenu-head { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: 14px; }
.usermenu-head .num { color: var(--muted); font-size: 13px; }
.usermenu-head .badge { align-self: flex-start; }
.usermenu-pop a, .usermenu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 12px; border: 0; background: none;
  color: var(--text); text-decoration: none; font-size: 14px; min-height: 0; justify-content: flex-start; box-shadow: none; }
.usermenu-pop a:hover, .usermenu-pop button:hover { background: var(--bg); color: var(--text); transform: none; }
.usermenu-pop form { margin: 0; }
.who-text { display: flex; flex-direction: column; line-height: 1.3; text-align: start; }
.who-text strong { font-size: 14px; } .who-text small { font-size: 13px; color: var(--muted); }
.rail-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* الأزرار والروابط شكلها أزرار */
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 18px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 14px; font-weight: 500;
  text-decoration: none; cursor: pointer; box-shadow: 0 1px 2px rgba(31, 29, 26, .04); transition: background .2s, border-color .2s, color .2s, box-shadow .2s, transform .2s; }
.btn:hover, button:hover { border-color: var(--accent-line); color: var(--accent); box-shadow: var(--shadow-hover); }
.btn.primary, button.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 18px -10px rgba(75, 91, 214, .9); }
.btn.primary:hover, button.primary:hover { color: #fff; transform: translateY(-1px); }
.btn.danger, button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost, button.ghost { border-color: transparent; background: none; color: var(--muted); box-shadow: none; }
.btn.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.btn.small, button.small { min-height: 34px; padding: 4px 14px; font-size: 13px; }
/* رابط يفتح شيئاً: حبة لونها خفيف وسهم */
.go { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); background: var(--accent-soft); text-decoration: none; font-weight: 500; font-size: 14px;
  white-space: nowrap; padding: 5px 12px; border-radius: 999px; transition: background .2s, color .2s; }
.go::after { content: '‹'; font-size: 16px; line-height: 1; }
.go:hover { background: var(--accent); color: #fff; }
/* البطاقات */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 1000px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
.card { background: var(--card); border: 1px solid rgba(236, 232, 225, .8); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 20px; font-weight: 700; margin-top: 4px; line-height: 1.35; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.panel { background: var(--card); border: 1px solid rgba(236, 232, 225, .8); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); min-width: 0; }
.panel h2 { font-size: 17px; margin: 0 0 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h3 { font-size: 17px; margin: 0; font-weight: 600; }
@media (max-width: 760px) { .panel { padding: 16px; border-radius: 20px; } .card { padding: 16px; border-radius: 20px; } }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; align-items: end; }
.filters > * { min-width: 0; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { width: 100%; min-width: 0; min-height: 42px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); font: inherit; font-size: 14px; transition: border-color .2s, background .2s, box-shadow .2s; }
textarea { font: inherit; font-size: 14px; resize: vertical; }
input[type=color] { padding: 4px; height: 40px; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 4px var(--accent-soft); }
.m-label { display: none; color: var(--muted); }
/* الجداول: صفوف منفصلة ناعمة، وعلى الموبايل تصير بطاقات (table.stack) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 14px; }
th { text-align: start; color: var(--muted); font-weight: 500; font-size: 13px; padding: 4px 12px; white-space: nowrap; }
td { padding: 12px; background: var(--row); vertical-align: middle; transition: background .2s; }
td:first-child { border-radius: 0 14px 14px 0; } td:last-child { border-radius: 14px 0 0 14px; }
.amt, td.fit { white-space: nowrap; }
td.fit { width: 1%; }
td.grow { min-width: 220px; }
@media (max-width: 760px) {
  table.stack, table.stack tbody { display: block; }
  table.stack thead { display: none; }
  table.stack .m-label { display: inline; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--row); border-radius: 16px; padding: 12px 14px; margin-bottom: 8px; }
  table.stack td { display: block; padding: 0; background: none; border-radius: 0; width: auto; min-width: 0; }
  table.stack td:first-child { flex: 1 1 100%; }
}
.small-badge { padding: 0 8px; margin-inline-start: 4px; }
.num { direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; }
div.num { text-align: right; }
.muted { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: var(--neutral-soft); color: var(--muted); }
.test { font-size: 13px; color: var(--warn); }
.notice { padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; font-size: 14px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-color: #f4d2ce; }
.auth { max-width: 420px; margin: 10vh auto; padding: 30px; }
.auth h2 { font-size: 22px; }
.auth::before { content: 'C'; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 16px; background: var(--grad); color: #fff; font-weight: 700; font-size: 20px;
  margin-bottom: 18px; box-shadow: 0 10px 20px -10px rgba(75, 91, 214, .7); }
.auth form { display: grid; gap: 14px; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0 14px; }
.or-line::before, .or-line::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.btn.google-btn { display: flex; width: 100%; justify-content: center; gap: 10px; background: var(--card); border: 1px solid var(--line-strong); color: var(--text); min-height: 44px; }
.btn.google-btn:hover { border-color: var(--accent); }
.prose { max-width: 720px; } .prose h3 { margin: 20px 0 6px; } .prose p { margin: 0 0 10px; }
.summary-preview { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: #fff; }
.summary-preview > div { padding: 20px !important; }
.pw { position: relative; display: block; }
.pw input { padding-left: 46px; }
.pw-eye { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 34px; min-height: 0; padding: 0; border: 0; border-radius: 10px;
  background: none; box-shadow: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.pw-eye:hover { color: var(--accent); background: var(--accent-soft); }
.pw-eye .icon:last-child, .pw-eye[aria-pressed=true] .icon:first-child { display: none; }
.pw-eye[aria-pressed=true] .icon:last-child { display: block; }
.copy { width: 100%; direction: ltr; font-size: 13px; }
.row input, .row select { width: auto; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 16px; }
.perm-grid label { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.perm-grid input { width: auto; min-height: auto; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; align-items: center; }
.pager .btn.small { min-width: 38px; padding: 4px 10px; }
.pager .gap { padding: 0 4px; }
button[disabled] { opacity: .45; cursor: not-allowed; }
.btn.disabled { opacity: .45; pointer-events: none; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 440px); gap: 20px; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: minmax(0, 1fr); } .editor-preview { position: static; } }
.editor-form .panel h3 { font-size: 16px; margin: 0 0 14px; }
.editor-form .panel h3 .muted { font-weight: 400; }
.editor-preview { position: sticky; top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.preview-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.preview-stage { padding: 16px; max-height: calc(100vh - 110px); overflow-y: auto; transition: background .2s; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
table.details { border-spacing: 0; } table.details td, table.details th { background: none; border-radius: 0; border-bottom: 1px solid var(--line); }
tr.clickable td:last-child { position: relative; padding-left: 34px; }
tr.clickable td:last-child:not(:has(.go))::after { content: '‹'; color: var(--muted); position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 16px; }
tr.clickable:hover td:last-child::after { color: var(--accent); }
table.details th { width: 200px; text-align: start; vertical-align: top; padding: 12px 8px; border-bottom: 1px solid var(--line); }
table.details tr:last-child th, table.details tr:last-child td { border-bottom: 0; }
@media (max-width: 560px) { table.details th { width: 110px; white-space: normal; } table.details td { word-break: break-word; } }
/* صفحة أو قسم فارغ: رسمة صغيرة وجملة وزر */
.empty { text-align: center; color: var(--muted); padding: 32px 8px; font-size: 14px; }
.empty-state { text-align: center; padding: 34px 16px; }
.empty-state .art { width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 26px; background: var(--accent-soft); display: grid; place-items: center; color: var(--accent); }
.empty-state .art .icon { width: 32px; height: 32px; }
.empty-state h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; } .empty-state p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
/* قائمة منسدلة ببحث: تحل محل كل select بصرياً، والأصلي يبقى في النموذج */
.cb { position: relative; min-width: 0; }
.cb-native { position: absolute !important; opacity: 0; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; pointer-events: none; bottom: 0; right: 0; }
.cb-btn { width: 100%; justify-content: space-between; background: var(--bg); font-size: 14px; text-align: start; border-radius: 12px; box-shadow: none; }
.cb-btn:hover { box-shadow: none; }
.cb-btn::after { content: ''; width: 7px; height: 7px; border-left: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg) translateY(-2px); flex: none; }
.cb-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-pop { position: fixed; z-index: 1000; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 40px -12px rgba(31, 29, 26, .22); padding: 6px; animation: rise .15s both; }
.cb-q { margin-bottom: 6px; min-height: 36px; }
.cb-list { max-height: 260px; overflow-y: auto; }
.cb-opt { padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.cb-opt:hover, .cb-opt.hl { background: var(--accent-soft); }
.cb-opt.on { color: var(--accent); font-weight: 600; }
.cb-opt[hidden] { display: none; }
.cb-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }
/* مفتاح تشغيل لكل ما يغيّر حالة */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 14px; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: #d8d3ca; position: relative; transition: background .2s; flex: none; }
.switch .thumb { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: right .2s; }
.switch input:checked + .track { background: var(--good); }
.switch input:checked + .track .thumb { right: 21px; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-form { display: inline-flex; margin: 0; }
/* لون: مربع صغير ورمزه */
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type=color] { width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: none; flex: none; cursor: pointer; }
.color-field input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-field input[type=color]::-webkit-color-swatch { border: none; border-radius: 7px; }
.color-field .hex { direction: ltr; font-size: 14px; color: var(--muted); font-family: ui-monospace, monospace; }
.fields-inline { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; }
/* صورة المنتج: رفع من الجهاز أو رابط */
.image-field { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.image-thumb { width: 96px; height: 60px; border-radius: 12px; border: 1px dashed var(--line-strong); background: var(--bg) center / cover no-repeat; flex: none; }
/* شريط فلاتر الحركات */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .cb { width: 180px; }
.toolbar .dates, .tx-chips .dates { display: flex; gap: 8px; align-items: center; }
.toolbar .dates input { width: 150px; }
.toolbar .dates[hidden], .tx-chips .dates[hidden] { display: none; }
.seg-inline { display: inline-flex; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .75); }
.seg-inline a { padding: 6px 14px; font-size: 14px; color: var(--muted); text-decoration: none; border-radius: 999px; white-space: nowrap; transition: background .2s, color .2s; }
.seg-inline a:hover { color: var(--text); }
.seg-inline a.on { background: var(--card); color: var(--accent); font-weight: 600; box-shadow: 0 2px 8px -2px rgba(31, 29, 26, .14); }
.clear-link { font-size: 13px; color: var(--muted); }
.tx-bar { padding: 0; background: none; border: 0; box-shadow: none; }
.tx-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-box { position: relative; flex: 1 1 280px; }
.search-box .icon, .sort-pick > .icon { position: absolute; top: 50%; right: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; z-index: 1; }
.search-box input { min-height: 50px; padding-right: 46px; border-radius: 999px; font-size: 15px; background: var(--card); border-color: var(--line); box-shadow: var(--shadow); }
.search-box input:hover { border-color: var(--accent-line); }
.sort-pick { position: relative; flex: none; }
.sort-pick .cb { width: 210px; }
.sort-pick .cb-btn { min-height: 50px; border-radius: 999px; padding-right: 44px; background: var(--card); border-color: var(--line); box-shadow: var(--shadow); }
.tx-chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.tx-chips .cb { width: auto; }
.tx-chips .cb-btn { width: auto; min-height: 36px; padding: 6px 14px; gap: 10px; border-radius: 999px; background: var(--card); border-color: var(--line); font-size: 14px; }
.tx-chips .cb:has(select.on) .cb-btn { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 600; }
.tx-chips .dates input { min-height: 36px; border-radius: 999px; padding: 6px 12px; width: 150px; background: var(--card); }
.tx-chips .seg-inline { margin-inline-start: auto; }
.tx-chips .clear-link { padding: 6px 4px; }
.tx-bar .range-line { margin-top: 10px; }
@media (max-width: 760px) {
  .sort-pick { flex: 1 1 100%; } .sort-pick .cb { width: 100%; }
  .tx-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding: 2px 16px 4px; }
  .tx-chips::-webkit-scrollbar { display: none; }
  .tx-chips > * { flex: none; }
  .tx-chips .seg-inline { margin-inline-start: 0; }
}
.range-line { margin-top: 12px; font-size: 13px; color: var(--muted); }
/* قوائم الحركات: أيقونة ملوّنة حسب النوع، والنص، والمبلغ؛ ومجمّعة حسب اليوم */
.tx-list { display: flex; flex-direction: column; }
.tx { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border-radius: var(--r-md); text-decoration: none; color: inherit; transition: background .2s; min-width: 0; }
.tx:hover { background: var(--row); }
.tx-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 15px; }
.tx-ic .icon { width: 19px; height: 19px; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-t1 { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-t2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-t2 .num { display: inline-block; max-width: 62%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.tx-side { display: flex; align-items: center; gap: 10px; flex: none; }
.tx-amt { font-weight: 600; font-size: 15px; text-align: left; white-space: nowrap; }
.tx-amt.neg { color: var(--bad); } .tx-amt.dim { color: var(--muted); font-weight: 500; }
.tx-amt small { font-weight: 400; font-size: 13px; color: var(--muted); }
.day-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 16px 10px 6px; }
.day-head:first-child { padding-top: 4px; }
.day-head span:last-child { font-weight: 500; display: flex; gap: 10px; }
@media (max-width: 760px) { .tx-side .badge { display: none; } .tx { padding: 10px 6px; } }

/* اللوحة: بطاقات الأرقام صف واحد متساوٍ، والرئيسية بتدرّج */
.overview-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: 1.3fr repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } .kpis .kpi.main { grid-column: 1 / -1; } }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
.kpi { background: var(--card); border: 1px solid rgba(236, 232, 225, .8); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  gap: 4px; position: relative; overflow: hidden; min-width: 0; transition: transform .25s, box-shadow .25s; }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.kpi .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.kpi.main { background: var(--grad); color: #fff; border: 0; box-shadow: 0 20px 40px -20px rgba(75, 91, 214, .8); }
.kpi.main::after { content: ''; position: absolute; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .12); left: -60px; bottom: -90px; pointer-events: none; }
.kpi.main .label, .kpi.main .more-cur { color: rgba(255, 255, 255, .88); }
.kpi.main .ic { background: rgba(255, 255, 255, .2); color: #fff; }
.kpi.main .delta { background: rgba(255, 255, 255, .2); color: #fff; }
.kpi .label { color: var(--muted); font-size: 14px; }
.kpi .value { font-size: 26px; font-weight: 700; line-height: 1.25; }
.kpi .more-cur { font-size: 16px; font-weight: 600; color: var(--muted); }
.kpi .note { font-size: 13px; color: var(--muted); }
@media (max-width: 760px) { .kpi { padding: 16px; } .kpi .value { font-size: 21px; } .kpi .ic { width: 34px; height: 34px; margin-bottom: 4px; } }
.delta { display: inline-flex; white-space: nowrap; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; padding: 2px 9px; border-radius: 999px; width: fit-content; margin-top: 6px; }
.delta.up { color: var(--good); background: var(--good-soft); } .delta.down { color: var(--bad); background: var(--bad-soft); } .delta.flat { color: var(--muted); background: var(--neutral-soft); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; margin-bottom: 0; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 1000px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
.grid-main > .panel { margin-bottom: 20px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.grid-2 > .panel { margin-bottom: 20px; }
/* مخطط الدخل: خط ناعم ومساحة ملوّنة تحته، والأحدث على اليسار */
.chart-plot { position: relative; height: 240px; margin-right: 64px; }
.chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; }
.chart-grid .gl { border-top: 1px solid var(--grid); height: 0; position: relative; }
.chart-grid .gl span { position: absolute; right: -64px; top: -10px; width: 58px; font-size: 13px; color: var(--muted); direction: ltr; text-align: left; white-space: nowrap; }
.chart-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), 1fr); align-items: end; }
.bar-slot { height: 100%; position: relative; cursor: default; }
.bar-slot .dot { position: absolute; left: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: #fff; border: 2.5px solid var(--accent); opacity: 0; transition: opacity .15s; }
.bar-slot::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px dashed var(--accent-line); opacity: 0; transition: opacity .15s; }
.bar-slot:hover .dot, .bar-slot:focus-visible .dot, .bar-slot:hover::before, .bar-slot:focus-visible::before { opacity: 1; }
.chart-x { display: flex; justify-content: space-between; margin-right: 64px; margin-top: 8px; }
.chart-x span { font-size: 13px; color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) { .chart-plot { height: 190px; } }
.chart-table { margin-top: 10px; font-size: 13px; }
.chart-table summary { color: var(--muted); cursor: pointer; }
.chart-tip { position: absolute; z-index: 100; background: var(--text); color: #fff; font-size: 13px; padding: 6px 10px; border-radius: 10px; pointer-events: none; white-space: nowrap; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .4); }
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); text-decoration: none; border-radius: 8px; }
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { background: var(--accent-soft); }
.alerts { display: flex; flex-direction: column; gap: 8px; }
.grid-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1000px) { .grid-even { grid-template-columns: minmax(0, 1fr); } }
.grid-even > .panel { margin-bottom: 20px; }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 10px; border-radius: var(--r-md); text-decoration: none; font-size: 14px; transition: background .2s; }
.list-row:hover { background: var(--row); }
.list-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.list-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list-text > span:first-child { font-size: 15px; font-weight: 500; }
.list-text small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.list-row > strong, .list-side strong { white-space: nowrap; flex: none; }
.list-side strong + strong { font-weight: 400; font-size: 13px; color: var(--muted); }
.proj-pic { width: 40px; height: 40px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.share { display: block; height: 8px; border-radius: 99px; background: var(--neutral-soft); overflow: hidden; margin-top: 6px; }
.share span { display: block; height: 100%; background: var(--grad); border-radius: 99px; }
.alert-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-md); text-decoration: none; font-size: 15px; background: var(--row); transition: filter .2s; }
.alert-row:hover { filter: brightness(.98); }
.alert-row .aic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.alert-row .aic .icon { width: 19px; height: 19px; }
.alert-row .grow { flex: 1; min-width: 0; font-weight: 500; } .alert-row small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-row.bad { background: var(--bad-soft); } .alert-row.bad .aic { background: #fbdcd8; color: var(--bad); }
.alert-row.warn { background: var(--warn-soft); } .alert-row.warn .aic { background: #f8e6bf; color: var(--warn); }
.alert-row.neutral .aic { background: var(--neutral-soft); color: var(--muted); }
.count-badge { background: var(--bad-soft); color: var(--bad); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
.cur-tabs { display: inline-flex; background: var(--neutral-soft); border-radius: 999px; padding: 3px; }
.cur-tabs button { min-height: 30px; padding: 4px 14px; border: 0; background: none; font-size: 13px; color: var(--muted); border-radius: 999px; box-shadow: none; }
.cur-tabs button:hover { box-shadow: none; transform: none; }
.cur-tabs button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.mini-main { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.mini-side { display: flex; flex-direction: column; align-items: flex-end; font-size: 14px; }
.payout-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding: 12px; border-radius: var(--r-md); background: var(--row); font-size: 14px; }
.payout-line .btn { margin-inline-start: auto; }
/* نافذة التأكيد */
.confirm-list { margin: 12px 0 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 14px; max-height: 260px; overflow-y: auto; }
.confirm-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.confirm-list li:last-child { border-bottom: 0; }
.confirm-list label { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.confirm-list input { width: auto; min-height: 0; }
.confirm-msg { white-space: pre-line; font-size: 15px; margin-top: 14px; }
.switch .state { font-size: 13px; color: var(--muted); min-width: 42px; }
.icon { flex: none; vertical-align: middle; }
/* قواعد الربط بجمل مفهومة */
.explain p { margin: 0 0 12px; max-width: 760px; }
.rules { display: flex; flex-direction: column; gap: 8px; }
.rule { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); margin: 0; transition: border-color .2s; }
.rule:hover { border-color: var(--line-strong); }
.rule.example { background: var(--bg); border-style: dashed; justify-content: flex-start; }
.rule-text { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; min-width: 0; }
.rule-text .icon { color: var(--muted); }
.rule-text .cb { width: 200px; }
.rule-arrow { color: var(--accent); font-weight: 600; }
.panel.attention { border-color: #f0dcae; background: #fffcf5; }
.panel.attention h3 { display: inline-flex; align-items: center; gap: 8px; color: var(--warn); }
.auto-rules { margin-top: 14px; }
.steps { margin: 8px 0; padding-inline-start: 20px; font-size: 14px; display: grid; gap: 8px; }
.auto-rules summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 0; }
.auto-rules .rules { margin-top: 8px; }
.switch input:checked ~ .state { color: var(--good); font-weight: 600; }
.crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.crumbs a { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 500; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--muted); }
dialog.modal { border: none; border-radius: 22px; padding: 0; width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  color: var(--text); background: var(--card); box-shadow: 0 24px 64px rgba(31, 29, 26, .28); }
dialog.modal[open] { animation: rise .2s both; }
dialog.modal::backdrop { background: rgba(31, 29, 26, .35); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-body { padding: 4px 22px 22px; }
.modal-foot { display: flex; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.field { margin-top: 20px; }
.field-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .seg { grid-template-columns: 1fr; } }
.seg label { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; color: var(--text); font-size: 14px; background: var(--card); transition: border-color .2s, background .2s; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg input { width: auto; min-height: auto; margin-top: 4px; box-shadow: none; }
.seg span { display: grid; gap: 2px; }
.seg small { color: var(--muted); font-size: 13px; }
.picker .row input[type=search] { flex: 1; width: auto; }
.picker-list { margin-top: 8px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.picker-list label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.picker-list label:hover { background: var(--accent-soft); }
.picker-list label[hidden], .perm-grid label[hidden] { display: none; }
.picker-list input { width: auto; min-height: auto; }
.tg-link { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
@media (max-width: 560px) { .tg-link { grid-template-columns: 1fr; } .tg-link .qr { max-width: 200px; margin: 0 auto; } }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
.tg-steps p { margin: 0 0 10px; font-size: 14px; }
/* ألوان حسب النوع (في آخر الملف لتغلب ألوان العناصر الافتراضية) */
:is(.ic, .tx-ic, .proj-pic, .aic, .badge).t-good { background: var(--good-soft); color: var(--good); }
:is(.ic, .tx-ic, .proj-pic, .aic, .badge).t-bad { background: var(--bad-soft); color: var(--bad); }
:is(.ic, .tx-ic, .proj-pic, .aic, .badge).t-warn { background: var(--warn-soft); color: var(--warn); }
:is(.ic, .tx-ic, .proj-pic, .aic, .badge).t-acc { background: var(--accent-soft); color: var(--accent); }
:is(.ic, .tx-ic, .proj-pic, .aic, .badge).t-info { background: var(--info-soft); color: var(--info); }
:is(.ic, .tx-ic, .proj-pic, .aic, .badge).t-neutral { background: var(--neutral-soft); color: var(--muted); }
.links-list .tx { align-items: flex-start; flex-wrap: wrap; }
.link-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
