/* ===== الخطوط ===== */
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/static/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(/static/fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/static/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/static/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/static/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(/static/fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/static/fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/static/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }

/* ===== ألوان الهوية ===== */
:root {
  color-scheme: light;
  --bg: #F2F4F8;
  --surface: #FFFFFF;
  --surface-2: #F6F8FB;
  --ink: #0B1B3A;
  --ink-2: #4B5573;
  --muted: #8790A8;
  --line: #E3E7EF;
  --line-2: #D2D8E4;
  --primary: #091F44;
  --primary-2: #14306A;
  --primary-soft: #E8EDF7;
  --accent: #2F63D6;
  --accent-soft: #E6EEFC;
  --arc: rgba(92, 132, 222, .38);
  --green: #16915C;
  --green-soft: #DDF3E8;
  --orange: #C77A0A;
  --orange-soft: #FCF0DC;
  --red: #C8372D;
  --red-soft: #FBE6E4;
  --gray-soft: #E6E9F0;
  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(9, 31, 68, .04), 0 4px 14px rgba(9, 31, 68, .05);
  --nav-h: 70px;
  --side-w: 256px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Plex Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--primary-2); }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }
p { margin: 0; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.green { color: var(--green); }
.red { color: var(--red); }
.orange { color: var(--orange); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.num, [dir=ltr] { font-variant-numeric: tabular-nums; }

/* ===== الشعار والأيقونات ===== */
.logo-svg { display: block; height: 100%; width: auto; }
.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.i-sm { width: 18px; height: 18px; }
.i-lg { width: 26px; height: 26px; }

/* ===== المبالغ ===== */
.amt { display: inline-flex; align-items: baseline; font-weight: 600; white-space: nowrap; unicode-bidi: isolate; }
.amt small { font-size: .62em; font-weight: 600; }
.amt i { font-style: normal; font-size: .6em; font-weight: 500; color: inherit; opacity: .7; margin-right: 5px; }
.amt.big { font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.amt.lg { font-size: 22px; font-weight: 700; }
.amt.md { font-size: 17px; }

/* ===== الهيكل ===== */
.app { min-height: 100vh; }
.side { display: none; }
.main { min-width: 0; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; min-height: 60px;
  background: rgba(242, 244, 248, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.topbar h1 { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .ttl { flex: 1; min-width: 0; }
.topbar .back { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.topbar .actions { display: flex; gap: 8px; }
.topbar .brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar .brand-logo { height: 30px; color: var(--primary); }
.topbar .today { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.content { padding: 4px 16px 16px; max-width: 1140px; margin: 0 auto; }

.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 500; padding: 6px 0; position: relative; }
.bottom-nav a.on { color: var(--primary); font-weight: 600; }
.bottom-nav a.on::before { content: ''; position: absolute; top: -1px; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.bottom-nav .fab span {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px;
  background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(9, 31, 68, .28);
}
.bottom-nav .fab .i { width: 26px; height: 26px; stroke-width: 2.4; }

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: var(--side-w) 1fr; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 40px; }
  .side {
    display: flex; flex-direction: column; gap: 2px;
    position: sticky; top: 0; height: 100vh; padding: 24px 14px 18px;
    background: var(--primary); color: #fff; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin;
  }
  .side::before { content: ''; position: absolute; width: 560px; height: 560px; border-radius: 50%; border: 1.5px solid var(--arc); left: -420px; bottom: -260px; pointer-events: none; }
  .side .brand { display: flex; flex-direction: column; gap: 8px; padding: 2px 12px 22px; }
  .side .brand .logo-wrap { height: 40px; color: #fff; }
  .side .brand b { font-size: 12.5px; font-weight: 500; color: rgba(255, 255, 255, .6); line-height: 1.4; }
  .side a.nav { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: rgba(255, 255, 255, .72); font-weight: 500; }
  .side a.nav:hover { background: rgba(255, 255, 255, .06); color: #fff; }
  .side a.nav.on { background: rgba(255, 255, 255, .1); color: #fff; font-weight: 600; }
  .side a.nav.on::before { content: ''; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #7FA6FF; }
  .side .sep { height: 1px; background: rgba(255, 255, 255, .1); margin: 8px 8px; flex: none; }
  .side .grow { flex: 1; }
  .side .new-deal { margin: 0 0 14px; background: #fff; color: var(--primary); }
  .side .new-deal:hover { background: #E9EEF9; color: var(--primary); }
  .side .out { background: transparent; color: rgba(255, 255, 255, .75); border: 1px solid rgba(255, 255, 255, .18); }
  .side .out:hover { background: rgba(255, 255, 255, .06); color: #fff; }
  .topbar { padding: 20px 28px 10px; background: transparent; backdrop-filter: none; position: static; }
  .topbar h1 { font-size: 24px; }
  .topbar .brand-logo { display: none; }
  .content { padding: 6px 28px 28px; }
}

/* ===== البطاقات ===== */
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 18px; }
.card + .card, .card + .section, .section + .card, .section + .section, .kpis + .card, .card + .kpis { margin-top: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2, .card-title h3 { font-size: 16.5px; display: flex; align-items: center; gap: 8px; }
.card-title a { font-size: 13.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 2px; }
.section { margin-top: 18px; }
.section > h2 { font-size: 16.5px; margin: 0 2px 10px; }
.sq { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex: none; }
.sq.navy { background: var(--primary-soft); color: var(--primary); }
.sq.blue { background: var(--accent-soft); color: var(--accent); }
.sq.green { background: var(--green-soft); color: var(--green); }
.sq.orange { background: var(--orange-soft); color: var(--orange); }
.sq.red { background: var(--red-soft); color: var(--red); }

/* لوحة بيانات عامة (العميل، السداد، النسخ) */
.hero { border-radius: var(--radius); padding: 18px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--primary); }
.hero .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero .label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.hero .label .i { width: 17px; height: 17px; color: var(--muted); }
.hero .main-num { margin-top: 4px; }
.hero .divider { height: 1px; background: var(--line); margin: 14px 0; }
.hero .grid2 { display: grid; grid-template-columns: 1fr 1fr; }
.hero .grid2 > div + div { border-inline-start: 1px solid var(--line); padding-inline-start: 16px; }
.hero .sub { font-size: 12.5px; font-weight: 500; }

/* البطاقة الكحلية الرئيسية */
.brand-hero { position: relative; overflow: hidden; border-radius: 20px; padding: 20px 20px 18px; background: var(--primary); color: #fff; }
.brand-hero::before, .brand-hero::after { content: ''; position: absolute; border-radius: 50%; border: 1.5px solid var(--arc); pointer-events: none; }
.brand-hero::before { width: 460px; height: 460px; left: -250px; top: -150px; }
.brand-hero::after { width: 300px; height: 300px; left: -190px; top: 40px; opacity: .6; }
.brand-hero > * { position: relative; }
.brand-hero .k { font-size: 13.5px; color: rgba(255, 255, 255, .7); font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand-hero .k a { color: #fff; font-size: 13px; display: inline-flex; align-items: center; opacity: .85; }
.brand-hero .amt.big { color: #fff; margin-top: 4px; }
.brand-hero .meter { margin-top: 14px; }
.brand-hero .meter .bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.brand-hero .meter .bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #7FA6FF, #B9CEFF); }
.brand-hero .meter .t { display: flex; flex-wrap: wrap; gap: 2px 12px; justify-content: space-between; font-size: 12.5px; color: rgba(255, 255, 255, .72); margin-top: 6px; }
.brand-hero .row3 { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .12); }
.brand-hero .row3 > div + div { border-inline-start: 1px solid rgba(255, 255, 255, .12); padding-inline-start: 12px; }
.brand-hero .row3 .l { font-size: 12px; color: rgba(255, 255, 255, .62); }
.brand-hero .row3 .v { font-size: 15.5px; font-weight: 700; }
.brand-hero .row3 .v.red { color: #FF9C94; }

/* مربعات المؤشرات */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 8px; color: var(--ink); }
a.kpi:hover { border-color: var(--line-2); color: var(--ink); }
.kpi .top { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 500; line-height: 1.3; }
.kpi .sq { width: 30px; height: 30px; border-radius: 9px; }
.kpi .sq .i { width: 17px; height: 17px; }
.kpi .amt { font-size: 18px; font-weight: 700; }
.kpi .delta { font-size: 12px; font-weight: 600; }

/* توزيع الصفقات */
.dist-bar { display: flex; gap: 3px; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.dist-bar span { display: block; height: 100%; min-width: 6px; }
.c-regular { background: var(--accent); } .c-collecting { background: #E7A23B; } .c-overdue { background: var(--red); }
.c-completed { background: var(--green); } .c-defaulted { background: #4A1512; } .c-draft { background: #B8C0D2; }
.dist-legend { margin-top: 10px; display: grid; grid-template-columns: 1fr; }
@media (min-width: 560px) { .dist-legend { grid-template-columns: 1fr 1fr; column-gap: 24px; } }
.dist-legend a { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.dist-legend a b { margin-inline-start: auto; font-size: 16px; }
.dist-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* قائمة الأقساط القادمة ببطاقة التاريخ */
.due-list { display: flex; flex-direction: column; }
.due { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.due:last-child { border-bottom: 0; }
.due .body { flex: 1; min-width: 0; }
.due .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due .meta { font-size: 12.5px; color: var(--muted); }
.datetile { width: 50px; flex: none; border-radius: 12px; background: var(--primary-soft); color: var(--primary); text-align: center; padding: 6px 0 5px; line-height: 1.1; }
.datetile .d { display: block; font-size: 19px; font-weight: 700; }
.datetile .m { display: block; font-size: 11px; font-weight: 500; }
.datetile.today { background: var(--primary); color: #fff; }
.datetile.late { background: var(--red-soft); color: var(--red); }

/* رأس الصفقة */
.deal-head { background: var(--surface); border-radius: 20px; overflow: hidden; border: 1px solid var(--line); }
.deal-head .band { position: relative; overflow: hidden; background: var(--primary); color: #fff; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.deal-head .band::before { content: ''; position: absolute; width: 360px; height: 360px; border-radius: 50%; border: 1.5px solid var(--arc); left: -220px; top: -120px; }
.deal-head .band > * { position: relative; }
.deal-head .band a { color: #fff; font-weight: 700; font-size: 17px; }
.deal-head .band .d { font-size: 12.5px; color: rgba(255, 255, 255, .7); }
.deal-head .stats { display: grid; grid-template-columns: 1fr 1fr; }
.deal-head .st { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.deal-head .st:nth-child(odd) { border-inline-end: 1px solid var(--line); }
.deal-head .st .l { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.deal-head .foot { padding: 12px 18px 16px; }
.deal-head .foot .t { display: flex; flex-wrap: wrap; gap: 2px 12px; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }

.progress { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #5C8BF0); }

/* تبويبات بخط سفلي */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); overflow-x: auto; scrollbar-width: none; margin-bottom: 14px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 11px 14px; color: var(--ink-2); font-weight: 600; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--accent); }

/* جدول الدفعات كخط زمني عمودي */
.tl { position: relative; padding-inline-start: 24px; }
.tl::before { content: ''; position: absolute; inset-inline-start: 8px; top: 18px; bottom: 18px; width: 2px; background: var(--line-2); }
.tl-item { position: relative; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.tl-item + .tl-item { margin-top: 10px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -23px; top: 50%; width: 12px; height: 12px; margin-top: -8px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line-2); }
.tl-item.paid::before { background: var(--green); border-color: var(--green); }
.tl-item.upcoming::before { border-color: var(--accent); }
.tl-item.collecting::before { border-color: #E7A23B; background: #FFF6E6; }
.tl-item.overdue::before { border-color: var(--red); background: var(--red-soft); }
.tl-item .body { flex: 1; min-width: 0; }
.tl-item .t { font-weight: 600; }
.tl-item .s { font-size: 12.5px; color: var(--muted); }
.tl-item .end { text-align: end; }
.tl-item .st { font-size: 12px; font-weight: 600; }
.tl-item.paid .st { color: var(--green); } .tl-item.upcoming .st { color: var(--accent); }
.tl-item.collecting .st { color: var(--orange); } .tl-item.overdue .st { color: var(--red); }
.tl-item details { position: relative; }
.tl-item details summary { list-style: none; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 8px; }
.tl-item details summary::-webkit-details-marker { display: none; }
.tl-item details[open] summary { background: var(--surface-2); }
.tl-item .pop { position: absolute; inset-inline-end: 0; top: 38px; z-index: 5; width: 250px; background: var(--surface); border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(9, 31, 68, .16); padding: 14px; }

/* ===== القوائم ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--radius-md); padding: 14px 16px;
  border: 1px solid var(--line); color: var(--ink);
}
a.item:hover { border-color: var(--line-2); color: var(--ink); }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.item .end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: end; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 16px; flex: none; }
.avatar.company { background: var(--accent-soft); color: var(--accent); }
.list.flat { gap: 0; }
.list.flat .item { border-radius: 0; border: 0; border-bottom: 1px solid var(--line); padding: 12px 2px; background: transparent; }
.list.flat .item:last-child { border-bottom: 0; }

/* ===== الشارات ===== */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1.7; }
.pill.lg { padding: 4px 12px; font-size: 13.5px; }
.pill.paid, .pill.completed { background: var(--green-soft); color: #0F6E45; }
.pill.upcoming, .pill.regular { background: var(--accent-soft); color: #2552B4; }
.pill.collecting { background: var(--orange-soft); color: #95590A; }
.pill.overdue { background: var(--red-soft); color: #A62B22; }
.pill.defaulted { background: #4A1512; color: #fff; }
.pill.draft, .pill.gray { background: var(--gray-soft); color: var(--ink-2); }
.pill.warn { background: var(--orange-soft); color: #95590A; }
.pill.on-dark { background: rgba(255, 255, 255, .14); color: #fff; }
.dot-s { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot-s.paid { background: var(--green); } .dot-s.upcoming { background: var(--accent); } .dot-s.collecting { background: #E7A23B; } .dot-s.overdue { background: var(--red); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 10px; background: var(--surface); color: var(--ink-2); font-weight: 500; font-size: 14px; white-space: nowrap; border: 1px solid var(--line-2); }
.chips a.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chips a b { font-size: 12px; background: rgba(9, 31, 68, .07); padding: 0 7px; border-radius: 6px; }
.chips a.on b { background: rgba(255, 255, 255, .2); }

/* ===== الأزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 12px; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 15px;
  background: var(--primary); color: #fff; white-space: nowrap;
  transition: transform .06s ease, background .15s ease;
}
.btn:hover { background: var(--primary-2); color: #fff; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
.btn.ghost:hover { border-color: var(--ink-2); color: var(--ink); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.green { background: var(--green); color: #fff; }
.btn.green:hover { background: #127A4D; }
.btn.danger { background: var(--surface); color: var(--red); border: 1px solid #F0C4C0; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { height: 36px; padding: 0 13px; font-size: 14px; border-radius: 10px; }
.btn.icon { width: 42px; padding: 0; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row.end { justify-content: flex-end; }
.btn-row > form { display: contents; }

/* ===== النماذج ===== */
.form { display: flex; flex-direction: column; gap: 16px; }
.fgrid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) {
  .fgrid.c2 { grid-template-columns: 1fr 1fr; }
  .fgrid.c3 { grid-template-columns: 1fr 1fr 1fr; }
  .fgrid .span2 { grid-column: span 2; }
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .err { font-size: 13px; color: var(--red); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(47, 99, 214, .14); }
.input.bad { border-color: var(--red); background: #FFFBFB; }
.input[dir=ltr] { text-align: right; }
input[type=date].input, input[type=time].input { direction: ltr; text-align: right; }
select.input { appearance: none; -webkit-appearance: none; 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='%238790A8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; padding-left: 40px; }
.input-wrap { position: relative; }
.input-wrap .suffix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.input-wrap .input { padding-left: 52px; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice label { flex: 1; min-width: 120px; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; color: var(--ink-2); text-align: center; line-height: 1.25; }
.choice input:checked + span { border-color: var(--primary); background: var(--primary); color: #fff; }
.choice input:focus-visible + span { box-shadow: 0 0 0 4px rgba(47, 99, 214, .18); }
.form-card h2 { font-size: 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.form-card h2 .n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 13px; }
.checkline { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
.checkline input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--primary); }

/* ملخص حسبة الصفقة */
.calc { background: var(--surface-2); border-radius: var(--radius-md); padding: 14px 16px; border: 1px dashed var(--line-2); }
.calc .line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; }
.calc .line.total { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 10px; font-weight: 700; }
.calc .line.total .amt { font-size: 20px; color: var(--primary); }
.sched { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.sched th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.sched td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.crow { display: grid; grid-template-columns: 30px 1fr 1fr 42px; gap: 8px; align-items: center; }
.crow .idx { color: var(--muted); font-weight: 600; text-align: center; }
.crows { display: flex; flex-direction: column; gap: 8px; }
.csum { display: flex; justify-content: space-between; margin-top: 8px; font-weight: 600; font-size: 14px; }

/* ===== التنبيهات ===== */
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; border: 1px solid transparent; }
.flash.ok { background: var(--green-soft); color: #0E5F3B; border-color: #BFE7D2; }
.flash.error { background: var(--red-soft); color: #922820; border-color: #F2C8C3; }
.flash.info { background: var(--accent-soft); color: #1F4A9E; border-color: #CFDCF8; }
.flash.warn { background: var(--orange-soft); color: #7E4C06; border-color: #F3DCB2; }
.flash a { color: inherit; text-decoration: underline; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .i { width: 40px; height: 40px; stroke-width: 1.5; margin-bottom: 8px; }
.empty p { margin-bottom: 14px; }

/* ===== التفاصيل ===== */
.kv { display: grid; grid-template-columns: 1fr; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-size: 14px; flex: none; }
.kv .v { margin: 0; font-weight: 600; text-align: end; min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 720px) { .kv.c2 { grid-template-columns: 1fr 1fr; column-gap: 32px; } }

.head-card { display: flex; gap: 14px; align-items: center; }
.head-card .avatar { width: 56px; height: 56px; border-radius: 16px; font-size: 20px; }
.head-card h2 { font-size: 20px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.docs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 720px) { .docs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.doc { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.doc .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.doc .ic.green { background: var(--green-soft); color: var(--green); }
.doc .ic.red { background: var(--red-soft); color: var(--red); }
.doc .body { flex: 1; min-width: 0; }
.doc .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.doc { min-width: 0; }
.doc.missing { border-style: dashed; border-color: #EBC0BB; background: #FFFAF9; }
.upload-box { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--line-2); }
@media (min-width: 720px) { .upload-box { grid-template-columns: 1fr 1.4fr auto; align-items: end; } }
input[type=file].input { padding: 9px; height: auto; font-size: 14px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: start; font-weight: 600; color: var(--ink-2); background: var(--surface-2); padding: 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td.n, .tbl th.n { text-align: end; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

details.more { position: relative; }
details.more > summary { list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more .menu { position: absolute; inset-inline-end: 0; top: 50px; z-index: 25; width: 270px; background: var(--surface); border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(9, 31, 68, .18); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
details.more .menu button, details.more .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 10px; background: none; font: inherit; font-weight: 500; color: var(--ink); cursor: pointer; text-align: start; }
details.more .menu button:hover, details.more .menu a:hover { background: var(--surface-2); }
details.more .menu .danger { color: var(--red); }
details.more .menu form { margin: 0; }
details.more .menu .sub { padding: 8px 12px; border-top: 1px solid var(--line); margin-top: 4px; }

.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search .input-wrap { flex: 1; }
.search .i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-right: 44px; padding-left: 14px; }

.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-grid a, .menu-grid button { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-align: start; width: 100%; }
.menu-grid .sq { width: 40px; height: 40px; border-radius: 12px; }
.menu-grid form { margin: 0; }

/* صفحات الدخول */
.auth-wrap { position: relative; overflow: hidden; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--primary); }
.auth-wrap::before, .auth-wrap::after { content: ''; position: absolute; border-radius: 50%; border: 1.5px solid var(--arc); pointer-events: none; }
.auth-wrap::before { width: 900px; height: 900px; left: -520px; top: -200px; }
.auth-wrap::after { width: 620px; height: 620px; right: -380px; bottom: -300px; opacity: .6; }
.auth { position: relative; width: 100%; max-width: 440px; }
.auth .auth-logo { height: 58px; color: #fff; display: flex; justify-content: center; margin: 0 auto 16px; }
.auth h1 { text-align: center; font-size: 20px; color: #fff; }
.auth .lead { text-align: center; color: rgba(255, 255, 255, .7); margin: 4px 0 20px; }
.auth .card { border: 0; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.auth.wide { max-width: 560px; }
.auth > .flash { margin-bottom: 12px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.grid-2 > * { min-width: 0; }
.grid-2 > div > :first-child { margin-top: 0; }
@media (min-width: 960px) { .grid-2 { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; } }

.pager { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

/* ===== الطباعة ===== */
.print-page { background: #fff; }
.print-page .sheet { max-width: 900px; margin: 0 auto; padding: 28px 24px; }
.print-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 3px solid var(--primary); padding-bottom: 14px; margin-bottom: 18px; }
.print-head h1 { font-size: 20px; }
.print-head .p-logo { height: 42px; color: var(--primary); margin-bottom: 8px; }
.print-bar { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 24px; background: var(--bg); position: sticky; top: 0; }
@media print {
  .print-bar, .no-print { display: none !important; }
  body { background: #fff; font-size: 12.5px; }
  .print-page .sheet { padding: 0; max-width: none; }
  .tbl th { background: #F1F3F7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4; margin: 14mm 12mm; }
}
@media (max-width: 959px) { .topbar h1.hide-mobile { display: none; } }

/* ===== التقويم ===== */
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.cal-head { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--primary); color: #fff; }
.cal-head::before { content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%; border: 1.5px solid var(--arc); left: -170px; top: -120px; }
.cal-head b { position: relative; font-size: 17px; }
.cal-head .nav-a { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, .1); color: #fff; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 10px; }
.cal-grid .dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0 6px; }
.cal-grid .day { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0 7px; border-radius: 12px; color: var(--ink); border: 1px solid transparent; min-height: 54px; }
.cal-grid .day:hover { background: var(--surface-2); }
.cal-grid .day .n { font-weight: 600; font-size: 15px; line-height: 1; }
.cal-grid .day .dots { display: flex; gap: 3px; min-height: 7px; }
.cal-grid .day .dots .dot-s { width: 7px; height: 7px; }
.cal-grid .day.today .n { color: var(--accent); }
.cal-grid .day.sel { border-color: var(--accent); background: var(--accent-soft); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 14px 14px; font-size: 12.5px; color: var(--ink-2); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot-s.payout { background: #7A5AF8; }

/* ===== العقد والكشوف ===== */
.contract .c-intro { margin: 12px 0; line-height: 1.95; }
.contract .c-h { font-size: 15.5px; margin: 20px 0 8px; color: var(--primary); }
.contract .c-parties th { width: 22%; }
.contract .tbl th { background: var(--surface-2); }
.contract .c-clauses { margin: 0; padding-inline-start: 22px; line-height: 1.95; }
.contract .c-clauses li { margin-bottom: 4px; }
.contract .c-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 34px; }
.contract .c-sign div { display: flex; flex-direction: column; gap: 26px; padding-top: 12px; border-top: 2px solid var(--primary); }
.st-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; }
.st-grid > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); }
.st-grid span { font-size: 12px; color: var(--muted); }
.st-grid b { font-size: 16px; }
@media print {
  .contract .tbl, .contract .c-sign, .st-grid { break-inside: avoid; }
  .contract .c-h { break-after: avoid; }
}
.contract .tbl th, .print-page .st-grid span { white-space: normal; }
@media (max-width: 600px) { .contract .tbl th { width: 40% !important; font-size: 13px; } .st-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .hide-sm { display: none; } }

/* ===== عرض المرفقات ===== */
.doc-thumb { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 10px; overflow: hidden; flex: none; background: var(--surface-2); border: 1px solid var(--line); color: var(--primary); }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-thumb.pdf { gap: 0; align-content: center; }
.doc-thumb.pdf .i { width: 20px; height: 20px; }
.doc-thumb.pdf b { font-size: 9.5px; letter-spacing: .5px; color: var(--red); line-height: 1; }
a.body { text-decoration: none; }
.noscroll { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: rgba(6, 16, 36, .94); }
.viewer[hidden] { display: none; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); color: #fff; }
.viewer-title { flex: 1; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-x, .viewer-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .12); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.viewer-x { width: 40px; padding: 0; justify-content: center; }
.viewer-btn:hover, .viewer-x:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.viewer-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 12px 24px; }
.viewer-img { max-width: 100%; max-height: calc(100vh - 90px); object-fit: contain; border-radius: 6px; cursor: zoom-in; margin: auto; background: #fff; }
.viewer-img.zoom { max-width: none; max-height: none; cursor: zoom-out; margin: 0; }
.viewer-page { direction: ltr; background: #fff; border-radius: 4px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); max-width: 100%; height: auto; }
.viewer-msg { margin: auto; color: #fff; text-align: center; line-height: 2; }
