/* Baytna OS — App Styles (المجموعة 4A: الداشبورد والشاشات والحالات؛ 4B يصقل) */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ━━━ متغيّرات الثيم (ليل افتراضي) ━━━ */
:root {
  --color-bg:       #0f172a;
  --color-bg-2:     #131f38;
  --color-surface:  #1e293b;
  --color-surface-2:#243349;
  --color-border:   #334155;
  --color-text:     #e2e8f0;
  --color-muted:    #94a3b8;
  --color-primary:  #2563eb;
  --color-primary-2:#3b82f6;
  --color-success:  #22c55e;
  --color-warning:  #f59e0b;
  --color-danger:   #ef4444;
  --shadow:         0 10px 30px rgba(0,0,0,.35);
  --shadow-sm:      0 2px 10px rgba(0,0,0,.25);
  --font-base:      system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --radius:         14px;
  --radius-sm:      9px;
  --dock-h:         84px;
}

/* النهار (يوم) */
[data-theme="day"] {
  --color-bg:       #eef2f7;
  --color-bg-2:     #e6ecf5;
  --color-surface:  #ffffff;
  --color-surface-2:#f4f7fb;
  --color-border:   #d8e0ec;
  --color-text:     #16203a;
  --color-muted:    #5b6b85;
  --shadow:         0 10px 30px rgba(20,40,80,.10);
  --shadow-sm:      0 2px 10px rgba(20,40,80,.08);
}

/* تلقائي: يتبع النظام */
@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --color-bg:       #eef2f7;
    --color-bg-2:     #e6ecf5;
    --color-surface:  #ffffff;
    --color-surface-2:#f4f7fb;
    --color-border:   #d8e0ec;
    --color-text:     #16203a;
    --color-muted:    #5b6b85;
    --shadow:         0 10px 30px rgba(20,40,80,.10);
    --shadow-sm:      0 2px 10px rgba(20,40,80,.08);
  }
}

/* ألوان التمييز (4A.171) */
[data-accent="green"]  { --color-primary:#16a34a; --color-primary-2:#22c55e; }
[data-accent="purple"] { --color-primary:#7c3aed; --color-primary-2:#8b5cf6; }
[data-accent="orange"] { --color-primary:#ea580c; --color-primary-2:#f97316; }
[data-accent="teal"]   { --color-primary:#0d9488; --color-primary-2:#14b8a6; }
[data-accent="pink"]   { --color-primary:#db2777; --color-primary-2:#ec4899; }

html { font-size: 16px; }

body {
  font-family: var(--font-base);
  background: radial-gradient(1200px 600px at 80% -10%, var(--color-bg-2), var(--color-bg)) fixed;
  color: var(--color-text);
  min-height: 100vh;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
.muted { color: var(--color-muted); }
.small { font-size: .8rem; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   الدخول (المجموعة 3)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.login-page { display: flex; align-items: center; justify-content: center; padding: 2rem; }
#login-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2.5rem; max-width: 400px; width: 100%; text-align: center;
  box-shadow: var(--shadow);
}
#login-container h1 { color: var(--color-primary); margin-bottom: .5rem; }
#login-container p  { color: var(--color-muted); font-size: .9rem; margin-bottom: 2rem; }
#login-container input, #login-container button {
  display: block; width: 100%; padding: .75rem 1rem;
  border-radius: var(--radius-sm); font-size: 1rem; margin-bottom: .75rem;
}
#login-container input { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); }
#login-container button { background: var(--color-primary); color: #fff; border: none; cursor: pointer; font-weight: 600; }
.error { background: #7f1d1d; color: #fca5a5; padding: .75rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .875rem; }
.remember-row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--color-muted); margin-bottom: .75rem; }
.remember-row input { width: auto; margin: 0; }

/* جداول/أزرار مشتركة */
.users-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.users-table th, .users-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--color-border); text-align: right; }
.users-table th { color: var(--color-muted); font-weight: 600; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 6px; font-size: .75rem; }
.badge.active { background: #14532d; color: #86efac; }
.badge.blocked { background: #7f1d1d; color: #fca5a5; }
.form-grid { display: grid; gap: .6rem; max-width: 420px; margin: 1rem 0; }
.form-grid input, .form-grid select { padding: .6rem .75rem; border-radius: var(--radius-sm); background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); }
.btn { background: var(--color-primary); color: #fff; border: none; padding: .55rem 1rem; border-radius: var(--radius-sm); cursor: pointer; font-size: .85rem; font-weight: 600; transition: filter .15s, transform .1s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--color-primary); }
.btn.danger { background: var(--color-danger); }
.btn.muted  { background: var(--color-border); color: var(--color-text); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   شاشة الافتتاح (4A.056–061)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(800px 500px at 50% 30%, var(--color-surface), var(--color-bg));
  transition: opacity .6s ease, visibility .6s ease;
}
.splash.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { text-align: center; animation: fadeInUp .6s ease both; }
.splash-logo { font-size: 2.4rem; font-weight: 800; color: var(--color-primary); letter-spacing: .5px; }
.splash-welcome { margin-top: .75rem; font-size: 1.25rem; font-weight: 700; }
.splash-sub { margin-top: .25rem; color: var(--color-muted); }
.splash-loader { display: flex; gap: .4rem; justify-content: center; margin: 1.5rem 0 .75rem; }
.splash-loader span { width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary); animation: bounce 1s infinite ease-in-out; }
.splash-loader span:nth-child(2) { animation-delay: .15s; }
.splash-loader span:nth-child(3) { animation-delay: .3s; }
.splash-loading { color: var(--color-muted); font-size: .85rem; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   الشريط العلوي (4A.236)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.top-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.1rem;
  padding-top: calc(.7rem + env(safe-area-inset-top));
  padding-inline-start: calc(1.1rem + env(safe-area-inset-left));
  padding-inline-end: calc(1.1rem + env(safe-area-inset-right));
  background: color-mix(in srgb, var(--color-surface) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}
.tb-brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.app-logo { font-weight: 800; color: var(--color-primary); white-space: nowrap; }
.app-logo-link { display: inline-flex; line-height: 0; }
.app-logo-img { height: 30px; width: auto; max-width: 140px; object-fit: contain; }
.tb-date { color: var(--color-muted); font-size: .8rem; white-space: nowrap; }
.tb-clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .95rem; }
.tb-chips { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.tb-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  padding: .2rem .55rem; border-radius: 999px; font-size: .8rem; white-space: nowrap;
}
.tb-chip.is-urgent { background: #7f1d1d; border-color: #b91c1c; color: #fecaca; animation: pulse 2s infinite; }
.tb-actions { display: flex; align-items: center; gap: .25rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: transparent; border: 1px solid transparent; color: var(--color-text);
  font-size: 1.05rem; cursor: pointer; text-decoration: none; transition: background .15s, transform .1s;
}
.icon-btn:hover { background: var(--color-surface-2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.danger:hover { background: #7f1d1d; color: #fecaca; }

/* ━━━ المحتوى ━━━ */
.main-content {
  max-width: 1080px; margin: 0 auto;
  padding: 1.25rem 1.1rem calc(var(--dock-h) + 1.5rem + env(safe-area-inset-bottom));
}

/* ━━━ البطل/العناوين ━━━ */
.dash-hero { margin: .5rem 0 1.25rem; }
.hero-family-photo { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: var(--radius); margin-bottom: .9rem; box-shadow: var(--shadow-sm); }
.hero-title { font-size: 1.7rem; font-weight: 800; }
.hero-sub { color: var(--color-muted); margin-top: .25rem; }
.section-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .75rem; }
.section-link { display: inline-block; margin-top: .6rem; color: var(--color-primary); font-size: .85rem; text-decoration: none; }
.section-link:hover { text-decoration: underline; }
.dash-section { margin-bottom: 1.6rem; }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

/* ━━━ البطاقات ━━━ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}

/* بطاقة حالة العائلة (4A.016–033) */
.state-card {
  display: flex; align-items: center; gap: .85rem;
  padding: 1rem 1.15rem; border-radius: var(--radius);
  border: 1px solid var(--color-border); background: var(--color-surface);
  box-shadow: var(--shadow-sm); margin-bottom: 1rem;
}
.state-card .state-text { display: flex; flex-direction: column; }
.state-card .state-text strong { font-size: 1.05rem; }
.state-card .state-text span { color: var(--color-muted); font-size: .9rem; }
.state-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 22%, transparent); }
.state-ok        { border-inline-start: 4px solid var(--color-success); }
.state-ok .state-dot        { background: var(--color-success); color: var(--color-success); }
.state-attention { border-inline-start: 4px solid var(--color-warning); }
.state-attention .state-dot { background: var(--color-warning); color: var(--color-warning); }
.state-urgent    { border-inline-start: 4px solid var(--color-danger); }
.state-urgent .state-dot    { background: var(--color-danger); color: var(--color-danger); animation: pulse 1.6s infinite; }

/* كرت الطوارئ (4A.034) */
.emergency-card {
  display: flex; align-items: center; gap: .85rem;
  padding: 1rem 1.15rem; border-radius: var(--radius);
  background: linear-gradient(90deg, #7f1d1d, #991b1b); color: #fff;
  margin-bottom: 1rem; box-shadow: var(--shadow);
}
.emergency-card .emg-icon { font-size: 1.6rem; }
.emergency-card a { color: #fecaca; font-weight: 700; }

/* البانر الذكي (4A.103–117) */
.smart-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.5rem;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-2)); color: #fff;
  box-shadow: var(--shadow-sm);
}
.smart-banner.is-hidden { display: none; }
.banner-text { font-weight: 600; transition: opacity .35s ease; }
.banner-close { background: rgba(255,255,255,.2); border: none; color: #fff; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1; }
.banner-close:hover { background: rgba(255,255,255,.35); }

/* شبكة المال (4A.063–076) */
.money-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; }
.stat-card { text-align: center; display: flex; flex-direction: column; gap: .35rem; }
.stat-label { color: var(--color-muted); font-size: .8rem; }
.stat-num { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-num[data-pending] { color: var(--color-muted); }
.budget-bar-wrap { margin-top: 1rem; }
.budget-bar { height: 10px; border-radius: 999px; background: var(--color-surface-2); overflow: hidden; }
.budget-fill { height: 100%; background: linear-gradient(90deg, var(--color-primary), var(--color-primary-2)); transition: width .8s ease; }
.budget-note { margin-top: .5rem; font-size: .8rem; }

/* خلاصات الأحداث (feed) */
.feed { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.feed-item {
  display: flex; align-items: center; gap: .75rem;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: .7rem .85rem;
}
.feed-icon { font-size: 1.25rem; flex: none; }
.feed-body { display: flex; flex-direction: column; min-width: 0; }
.feed-label { font-weight: 600; }
.feed-meta { color: var(--color-muted); font-size: .8rem; }

/* بطاقة الرسوم (placeholder) */
.graph-card { min-height: 160px; display: flex; align-items: center; justify-content: center; }

/* ألسنة العروض الزمنية (4A.193–209) */
.view-tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
.view-tab {
  padding: .45rem .95rem; border-radius: 999px; text-decoration: none;
  background: var(--color-surface); border: 1px solid var(--color-border);
  color: var(--color-text); font-size: .85rem; font-weight: 600; transition: all .15s;
}
.view-tab:hover { border-color: var(--color-primary); }
.view-tab.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* بطاقات التنقّل (4A.175–183) */
.nav-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .85rem; }
.nav-card {
  display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1rem .6rem; text-decoration: none; color: var(--color-text);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.nav-card:hover { transform: translateY(-3px); border-color: var(--color-primary); box-shadow: var(--shadow-sm); }
.nav-icon { font-size: 1.6rem; }
.nav-title { font-weight: 700; font-size: .9rem; }
.nav-sub { color: var(--color-muted); font-size: .75rem; }
.nav-card.is-pending { opacity: .55; }
.nav-card.is-pending:hover { transform: none; }

/* ━━━ شريط فلترة ━━━ */
.filter-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.filter-bar select {
  padding: .5rem .75rem; border-radius: var(--radius-sm);
  background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); font-size: .85rem;
}

/* ━━━ حالة فارغة (4A) ━━━ */
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--color-muted); }
.empty-icon { font-size: 2.4rem; display: block; margin-bottom: .5rem; }
.pending-card .card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }

/* ━━━ شارات الحالة ━━━ */
.status-pill { padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.status-late { background: #7f1d1d; color: #fca5a5; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   مركز التنبيهات (4A.210–217)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.notif-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.notif-item {
  display: flex; align-items: center; gap: .75rem;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: .75rem .9rem;
}
.notif-item.is-unread { border-inline-start: 4px solid var(--color-primary); }
.notif-item.is-urgent { border-inline-start: 4px solid var(--color-danger); }
.notif-icon { font-size: 1.3rem; flex: none; }
.notif-body { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.notif-title { font-weight: 700; }
.notif-item.is-read .notif-title { font-weight: 500; color: var(--color-muted); }
.notif-text { font-size: .85rem; color: var(--color-muted); }
.notif-meta { font-size: .75rem; color: var(--color-muted); margin-top: .2rem; }
.notif-actions { display: flex; align-items: center; gap: .2rem; flex: none; }
.notif-actions form { display: inline; }
.notif-actions .icon-btn { width: 34px; height: 34px; font-size: .95rem; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   الرسائل الداخلية (4A.230–232)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.chat-thread {
  display: flex; flex-direction: column; gap: .5rem;
  max-height: 60vh; overflow-y: auto; padding: .5rem 0 1rem;
}
.chat-bubble { max-width: 78%; padding: .6rem .85rem; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.chat-bubble.is-mine { align-self: flex-start; background: var(--color-primary); color: #fff; border-bottom-inline-start: 4px solid transparent; }
.chat-bubble.is-theirs { align-self: flex-end; background: var(--color-surface); border: 1px solid var(--color-border); }
.bubble-text { display: block; }
.bubble-meta { display: block; margin-top: .25rem; font-size: .68rem; opacity: .75; }
.chat-composer { display: flex; gap: .5rem; margin-top: .5rem; }
.chat-input {
  flex: 1 1 auto; padding: .7rem .9rem; border-radius: 999px;
  background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); font-size: .95rem;
}
.chat-composer .btn { border-radius: 999px; padding: .7rem 1.3rem; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   زر الإجراء العائم + قائمته (4A.126–139)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.fab {
  position: fixed; inset-block-end: calc(var(--dock-h) + 14px + env(safe-area-inset-bottom)); inset-inline-end: 18px; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2)); color: #fff;
  font-size: 1.8rem; line-height: 1; box-shadow: var(--shadow);
  transition: transform .2s ease;
}
.fab:hover { transform: scale(1.06); }
.fab.is-open { transform: rotate(45deg); }

.quick-menu {
  position: fixed; inset-block-end: calc(var(--dock-h) + 80px + env(safe-area-inset-bottom)); inset-inline-end: 18px; z-index: 60;
  width: min(320px, 86vw);
  display: grid; grid-template-columns: 1fr 1fr; gap: .5rem;
  padding: .85rem; border-radius: var(--radius);
  background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow);
  transform-origin: bottom left; animation: popIn .18s ease both;
}
.quick-menu[hidden] { display: none; }
.quick-item {
  display: flex; align-items: center; gap: .5rem; padding: .55rem .6rem;
  border-radius: var(--radius-sm); text-decoration: none; color: var(--color-text);
  background: var(--color-surface-2); font-size: .82rem; transition: background .15s;
}
.quick-item:hover { background: var(--color-border); }
.quick-item.is-pending { opacity: .55; }
.qi-icon { font-size: 1.1rem; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Dock بنمط macOS (4A.234)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.dock {
  position: fixed; inset-block-end: calc(12px + env(safe-area-inset-bottom)); inset-inline: 0; z-index: 55;
  display: flex; gap: .35rem; justify-content: center; align-items: flex-end;
  margin: 0 auto; padding: .4rem .55rem; width: max-content; max-width: calc(100vw - 24px);
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(16px);
  border: 1px solid var(--color-border); border-radius: 20px; box-shadow: var(--shadow);
  overflow-x: auto;
}
/* زر الداشبورد المركزي البارز (B3) */
.dock-item[data-key="home"] .dock-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-top: -16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #fff; box-shadow: var(--shadow); border: 3px solid var(--color-bg);
}
.dock-item[data-key="home"].is-active .dock-icon { transform: scale(1.05); }
.dock-item {
  position: relative; flex: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 58px; padding: .35rem .2rem; border-radius: 14px;
  text-decoration: none; color: var(--color-text);
  transition: transform .18s ease, background .15s;
}
.dock-item:hover { transform: translateY(-8px) scale(1.12); background: var(--color-surface-2); }
.dock-item.is-active { background: var(--color-surface-2); }
.dock-item.is-active::after { content: ""; position: absolute; inset-block-end: -3px; width: 5px; height: 5px; border-radius: 50%; background: var(--color-primary); }
.dock-item.is-pending { opacity: .5; }
.dock-icon { font-size: 1.4rem; }
.dock-label { font-size: .62rem; color: var(--color-muted); white-space: nowrap; }
.dock-badge {
  position: absolute; inset-block-start: 0; inset-inline-end: 6px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  background: var(--color-danger); color: #fff; font-size: .68rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   إشعارات Toast (4A.140–153)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.toast-container {
  position: fixed; inset-block-start: 70px; inset-inline: 0; z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: 90vw;
  padding: .7rem 1.1rem; border-radius: 999px; font-size: .88rem; font-weight: 600;
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); box-shadow: var(--shadow);
  animation: toastIn .25s ease both;
}
.toast.is-out { animation: toastOut .25s ease both; }
.toast.toast-success { border-color: var(--color-success); }
.toast.toast-warning { border-color: var(--color-warning); }
.toast.toast-danger  { border-color: var(--color-danger); }
.toast.toast-info    { border-color: var(--color-primary); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   أنيميشن (4A.118–125)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.fade-in { animation: fadeInUp .5s ease both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes popIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-12px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ═══════════════════════════════════════════════════════════
   المجموعة 4B — صقل التصميم والتجربة، الإتاحة، الإعدادات، التأثيرات
   ═══════════════════════════════════════════════════════════ */

/* ━━━ تفضيلات عامة (4B.055, 4B.060–061) ━━━ */
html[data-fontsize="large"] { font-size: 18.5px; }
html[data-banners="off"] .smart-banner { display: none; }
html[data-animations="off"] *,
html[data-animations="off"] *::before,
html[data-animations="off"] *::after { animation: none !important; transition: none !important; }

/* ━━━ الإتاحة (a11y) (4B.053–057) ━━━ */
:focus-visible { outline: 3px solid var(--color-primary-2); outline-offset: 2px; border-radius: 4px; }
.btn, .icon-btn, .view-tab, .seg-btn, .swatch, .nav-card { min-height: 40px; }   /* أهداف لمس كبيرة (4B.050) */
.skip-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ━━━ بحث الشريط العلوي (4B.030–032) ━━━ */
.tb-search { position: relative; flex: 1 1 220px; max-width: 360px; display: flex; align-items: center; }
.tb-search-ico { position: absolute; inset-inline-start: 10px; font-size: .9rem; opacity: .7; pointer-events: none; }
.tb-search input {
  width: 100%; padding: .45rem .8rem .45rem 2rem; border-radius: 999px;
  background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); font-size: .85rem;
}
.tb-mic { position: absolute; inset-inline-end: 6px; background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0 .2rem; }
.search-page-form { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.search-page-form input { flex: 1 1 auto; padding: .7rem 1rem; border-radius: 999px; background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); font-size: 1rem; }

/* ━━━ أيقونات الشريط العلوي (4B.025–029) ━━━ */
.tb-bell { position: relative; }
.tb-bell-badge { position: absolute; inset-block-start: 2px; inset-inline-end: 2px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px; background: var(--color-danger); color: #fff; font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }
.tb-avatar { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2)); color: #fff; font-weight: 800; }
.tb-avatar-link { display: inline-flex; line-height: 0; border-radius: 50%; }
.tb-avatar-img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--color-border); }

/* ━━━ زر "עוד" + لوح كل الشاشات (4B.022–023) ━━━ */
.dock-more { background: transparent; border: none; cursor: pointer; }
.more-sheet {
  position: fixed; inset-block-end: calc(var(--dock-h) + 6px); inset-inline: 12px; z-index: 58;
  margin: 0 auto; max-width: 520px;
  background: color-mix(in srgb, var(--color-surface) 95%, transparent);
  backdrop-filter: blur(16px); border: 1px solid var(--color-border);
  border-radius: 18px; box-shadow: var(--shadow); padding: 1rem; animation: popIn .18s ease both;
}
.more-sheet[hidden] { display: none; }
.more-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.more-item { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center;
  padding: .7rem .3rem; border-radius: 12px; text-decoration: none; color: var(--color-text); background: var(--color-surface-2); }
.more-item:hover { background: var(--color-border); }
.more-item.is-pending { opacity: .5; }
.more-icon { font-size: 1.4rem; }
.more-label { font-size: .72rem; }

/* ━━━ نافذة تأكيد عامة (4B.010–014) ━━━ */
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); padding: 1.5rem; animation: fadeInUp .2s ease both; }
.modal-overlay[hidden] { display: none; }
.modal-box { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 1.5rem; max-width: 380px; width: 100%; box-shadow: var(--shadow); text-align: center; animation: popIn .2s ease both; }
.modal-title { font-size: 1.1rem; margin-bottom: .5rem; }
.modal-message { color: var(--color-muted); margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .6rem; justify-content: center; }

/* ━━━ هيكل تحميل Skeleton + Loader + خطأ (4B.004–006) ━━━ */
.skeleton-list { display: flex; flex-direction: column; gap: .6rem; }
.skeleton-row { display: flex; align-items: center; gap: .6rem; }
.sk { background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border) 37%, var(--color-surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
.sk-avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; }
.sk-line { height: 14px; flex: 1 1 auto; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.loader { width: 32px; height: 32px; border: 3px solid var(--color-border); border-top-color: var(--color-primary);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 1rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { text-align: center; padding: 1.5rem; color: var(--color-danger); }
.error-state .empty-icon { color: var(--color-danger); }

/* ━━━ مؤشّرات الحفظ/المزامنة (4B.072–074) ━━━ */
.save-indicator { position: fixed; inset-block-start: 64px; inset-inline-start: 50%; transform: translateX(50%); z-index: 70;
  background: var(--color-success); color: #fff; padding: .35rem .85rem; border-radius: 999px; font-size: .8rem;
  opacity: 0; pointer-events: none; transition: opacity .3s; }
.save-indicator.show { opacity: 1; }

/* ━━━ شاشة الإعدادات (4B.062–071) ━━━ */
.settings-card { margin-bottom: 1.25rem; }
.seg { display: inline-flex; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 999px; padding: 3px; gap: 3px; }
.seg-btn { background: transparent; border: none; color: var(--color-text); padding: .45rem .9rem; border-radius: 999px; cursor: pointer; font-size: .85rem; font-weight: 600; }
.seg-btn.is-active { background: var(--color-primary); color: #fff; }
.swatches { display: flex; gap: .6rem; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.is-active { border-color: var(--color-text); }
.sw-blue { background: #2563eb; } .sw-green { background: #16a34a; } .sw-purple { background: #7c3aed; }
.sw-orange { background: #ea580c; } .sw-teal { background: #0d9488; } .sw-pink { background: #db2777; }
.switch-row, .perm-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--color-border); }
.switch-row > span:first-child, .perm-row > span:first-child { flex: 1 1 auto; }
.switch-row:last-child, .perm-row:last-child { border-bottom: none; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; border-radius: 999px; background: var(--color-border); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch:checked { background: var(--color-success); }
.switch:checked::after { transform: translateX(-20px); }
.perm-status { font-size: .75rem; color: var(--color-muted); min-width: 56px; text-align: center; }
.perm-status[data-state="granted"], .perm-status[data-state="installed"] { color: var(--color-success); }
.perm-status[data-state="denied"], .perm-status[data-state="dismissed"] { color: var(--color-danger); }
.future-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: .75rem; }

/* ترتيب كروت الداشبورد (4B.062–063) */
.card-order { list-style: none; display: flex; flex-direction: column; gap: .4rem; margin-top: .75rem; }
.card-order-row { display: flex; align-items: center; gap: .6rem; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: .5rem .7rem; }
.card-order-row.is-hidden { opacity: .5; }
.reorder { display: flex; flex-direction: column; }
.reorder .icon-btn { width: 24px; height: 20px; font-size: .7rem; }
.co-label { flex: 1 1 auto; }

/* ━━━ الإعداد الأولي (4B.075–089) ━━━ */
.guide-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.ob-head { display: flex; align-items: center; justify-content: space-between; }
.ob-count { font-weight: 800; color: var(--color-primary); }
.ob-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.ob-item { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-2); }
.ob-item.is-done { opacity: .65; }
.ob-item.is-done .ob-label { text-decoration: line-through; }
.ob-check-form { display: inline; }
.ob-check { background: none; border: none; font-size: 1.3rem; cursor: pointer; line-height: 1; }
.ob-icon { font-size: 1.2rem; }
.ob-body { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.ob-hint { font-size: .75rem; }
.ob-go { flex: none; }
.ready-card { text-align: center; padding: 2rem 1.25rem; background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2)); color: #fff; }
.ready-icon { font-size: 3rem; display: block; margin-bottom: .5rem; }
.ready-card .btn { margin-top: 1rem; background: rgba(255,255,255,.22); }

/* ━━━ سيكوم الداشبورد + تصاميم خاصة (4B.035–047, 4B.097–101) ━━━ */
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; }
.summary-card { display: flex; flex-direction: column; gap: .5rem; }
.summary-head { font-size: .95rem; }
.summary-list { list-style: none; display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; color: var(--color-muted); }
.summary-list strong { color: var(--color-text); }
.card--money .section-title::before   { content: "💰 "; }
.card--news .section-title::before     { content: "✨ "; }
.card--upcoming .section-title::before { content: "📌 "; }
.card--urgent { animation: pulse 1.8s infinite; }

/* ━━━ تأثيرات احتفالية مستقبلية (4B.111–117) ━━━ */
.confetti-piece { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 200; pointer-events: none; opacity: .9; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(540deg); opacity: 1; } }
.fx-birthday { animation: fxpop .9s ease; }
@keyframes fxpop { 0% { transform: scale(.8); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* ━━━ قائمة جانبية على الحاسوب (4B.023) — نفس الـDock عموديًا ━━━ */
@media (min-width: 1024px) {
  .dock {
    inset-block: 50% auto; inset-inline-start: 14px; inset-inline-end: auto;
    transform: translateY(-50%); flex-direction: column; width: auto; margin: 0;
    max-height: 86vh; overflow-y: auto; overflow-x: hidden;
  }
  .dock-item:hover { transform: translateX(-8px) scale(1.08); }
  .dock-item.is-active::after { inset-block-end: auto; inset-inline-start: -4px; inset-block-start: 50%; transform: translateY(-50%); }
  .dock-item[data-key="home"] .dock-icon { margin-top: 0; }  /* بلا رفع في الشريط العمودي */
  .main-content { padding-bottom: 1.75rem; padding-inline-start: 104px; }
  .fab { inset-block-end: 22px; }
  .more-sheet { inset-block-end: 22px; inset-inline-start: 104px; inset-inline-end: auto; }
}

/* ━━━ استجابة الجوال ━━━ */
@media (max-width: 720px) {
  .dash-cols { grid-template-columns: 1fr; }
  .nav-grid { grid-template-columns: repeat(2, 1fr); }
  .money-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .future-grid { grid-template-columns: repeat(2, 1fr); }
  .more-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-title { font-size: 1.4rem; }
  .tb-date { display: none; }
  .tb-search { display: none; }       /* البحث يُفتح من صفحة البحث في الجوال */

  /* Dock = شريط سفلي ثابت بعرض كامل بنمط تطبيق، بلا قصّ ولا تمرير (B3) */
  .dock {
    inset-block-end: 0; inset-inline: 0; width: auto; max-width: none; margin: 0;
    justify-content: space-around; gap: 0; overflow: visible;
    border-radius: 18px 18px 0 0; border-inline: none; border-bottom: none;
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .dock-item { flex: 1 1 0; width: auto; max-width: 84px; }
  .dock-item:hover { transform: none; background: transparent; }
  .dock-icon { font-size: 1.35rem; }
  .dock-label { font-size: .6rem; }
}

/* ═══════════════════════════════════════════════════════════
   المجموعة 5 — المال (ميزانيات/تقارير/مبالغ)
   ═══════════════════════════════════════════════════════════ */
.is-positive { color: var(--color-success); }
.is-negative { color: var(--color-danger); }

.budget-list, .report-list { display: flex; flex-direction: column; gap: .9rem; }
.budget-row-head, .report-row-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  font-size: .85rem; margin-bottom: .35rem;
}
.budget-row-head > span:last-child, .report-row-head > span:last-child { color: var(--color-muted); white-space: nowrap; }
.budget-fill.is-warn { background: linear-gradient(90deg, var(--color-warning), #fbbf24); }
.budget-fill.is-over { background: linear-gradient(90deg, var(--color-danger), #f87171); }
.report-row .budget-bar { height: 8px; }

/* ═══════════════════════════════════════════════════════════
   المجموعة 7 — البيت (مهام/مشتريات/ملاحظات/تثبيت)
   ═══════════════════════════════════════════════════════════ */
/* قوالب سريعة */
.chips-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip-btn { background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text);
  padding: .4rem .8rem; border-radius: 999px; font-size: .82rem; cursor: pointer; transition: background .15s; }
.chip-btn:hover { background: var(--color-border); }

/* أولوية المهمة — شريط جانبي ملوّن */
.feed-item.prio-critical { border-inline-start: 4px solid var(--color-danger); }
.feed-item.prio-urgent   { border-inline-start: 4px solid var(--color-warning); }
.feed-item.prio-important { border-inline-start: 4px solid var(--color-primary); }

/* عناوين أيام التقويم */
.day-head { font-size: .8rem; color: var(--color-muted); margin: .9rem 0 .4rem; font-weight: 700; }

/* الملاحظات اللاصقة */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.note-card { border-radius: 12px; padding: .85rem; color: #1f2937; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; min-height: 96px; }
.note-body { flex: 1 1 auto; font-size: .9rem; word-break: break-word; }
.note-foot { display: flex; align-items: center; justify-content: space-between; font-size: .72rem; opacity: .75; margin-top: .5rem; }
.note-btn { background: rgba(0,0,0,.08); border: none; border-radius: 6px; padding: .15rem .4rem; cursor: pointer; text-decoration: none; color: #1f2937; }

/* المثبّتات */
.pins-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.pin-card { display: flex; align-items: center; gap: .5rem; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: .6rem .7rem; text-decoration: none; color: var(--color-text); }
.pin-card:hover { border-color: var(--color-primary); }
.pin-type { font-size: 1.2rem; flex: none; }
.pin-title { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble-pin { background: none; border: none; cursor: pointer; font-size: .7rem; opacity: .5; padding: 0 .2rem; }
.bubble-pin:hover { opacity: 1; }

/* المجموعة 8 — صفّ تذكيرات الحدث */
.reminders-row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--color-muted); }
.reminders-row label { display: inline-flex; align-items: center; gap: .25rem; cursor: pointer; }

/* ═══════════════════════════════════════════════════════════
   المجموعة 9 — وسوم ملوّنة + تصدير + خلفيات + أنماط ألوان
   ═══════════════════════════════════════════════════════════ */
/* وسوم (9.014–9.022) */
.tags-row { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tag-chip { color: #fff; padding: .3rem .8rem; border-radius: 999px; font-size: .8rem; font-weight: 700; text-decoration: none; box-shadow: var(--shadow-sm); }
.tag-chip:hover { filter: brightness(1.08); }

/* خلفيات لطيفة (9.023) — طبقة خلف المحتوى */
html[data-background="dots"] body { background-image: radial-gradient(color-mix(in srgb, var(--color-primary) 22%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
html[data-background="waves"] body { background-image: repeating-linear-gradient(45deg, color-mix(in srgb, var(--color-primary) 7%, transparent) 0 12px, transparent 12px 24px); }
html[data-background="aurora"] body { background-image: radial-gradient(60% 50% at 15% 0%, color-mix(in srgb, var(--color-primary) 20%, transparent), transparent), radial-gradient(50% 50% at 100% 20%, color-mix(in srgb, var(--color-primary-2) 18%, transparent), transparent); background-attachment: fixed; }

/* نمط الألوان (9.024) */
html[data-colorstyle="vivid"] { --color-primary-2: color-mix(in srgb, var(--color-primary) 60%, #ffffff); }
html[data-colorstyle="mono"] { --color-primary: #475569; --color-primary-2: #64748b; }

/* شارات الحالة الزمنية (المجموعة 10 — 10.093–10.098) */
.dbadge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .68rem; font-weight: 700; color: #fff; }
.badge-late { background: var(--color-danger); }
.badge-today { background: var(--color-primary); }
.badge-tomorrow { background: var(--color-primary-2); }
.badge-week { background: #6366f1; }
.badge-month { background: #64748b; }

/* أنماط الطباعة (تصدير PDF عبر المتصفّح 9.001) */
@media print {
  #top-bar, #dock, #fab, #quick-menu, #more-sheet, #toast-container, .filter-bar, .tags-row { display: none !important; }
  .main-content { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
}
