/* ═══════════ جيران رسن — ستايل أبل فاخر ═══════════ */
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink2: #6e6e73;
  --line: rgba(0, 0, 0, .07);
  --topbar: rgba(255, 255, 255, .8);
  --r: 20px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 30px rgba(0, 0, 0, .06);
  --gold: #b8934a;   --gold-soft: #f6eedd;
  --silver: #7d858f; --silver-soft: #f0f2f5;
  --gun: #46566b;    --gun-soft: #e8edf3;
  --copper: #b06a3b; --copper-soft: #f8ecdf;
}
[data-theme="dark"] {
  --bg: #121419;
  --card: #1d2129;
  --ink: #edf0f4;
  --ink2: #98a2ae;
  --line: rgba(255, 255, 255, .09);
  --topbar: rgba(22, 25, 32, .85);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .3);
  --gold-soft: rgba(201, 169, 97, .16);
  --silver-soft: rgba(154, 161, 172, .16);
  --gun-soft: rgba(110, 128, 153, .2);
  --copper-soft: rgba(201, 138, 94, .16);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  background: linear-gradient(180deg, #f7f7f9 0%, #f1f1f4 100%);
  color: var(--ink); direction: rtl;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Arabic', 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  line-height: 1.55; padding-bottom: 76px;
}
[data-theme="dark"] body { background: linear-gradient(180deg, #15181e 0%, #101218 100%); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
a { color: inherit; text-decoration: none; }

/* ---------- الترويسة ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--topbar);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--line);
}
.topbar::after {
  content: ''; display: block; height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--silver), var(--gun), var(--copper));
  opacity: .55;
}
.topbar-inner {
  max-width: 900px; margin: 0 auto; padding: 13px 16px 11px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .dm {
  width: 15px; height: 15px; border-radius: 4px; transform: rotate(45deg);
  background: linear-gradient(135deg, #e3cb92, #a8873f);
  box-shadow: 0 0 0 1px rgba(184, 147, 74, .3);
}
.brand .t { font-weight: 800; font-size: 20px; letter-spacing: -.2px;
  background: linear-gradient(135deg, #8a6d2f, #c9a961 55%, #96773b);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand small { display: block; color: var(--ink2); font-weight: 700; font-size: 10.5px; line-height: 1.3; letter-spacing: .2px; }
.theme-btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  width: 40px; height: 40px; font-size: 17px; cursor: pointer; transition: all .2s;
}

.tabs { display: flex; gap: 4px; background: rgba(0, 0, 0, .055); border-radius: 13px; padding: 4px; }
.tab {
  border: 0; background: transparent; color: var(--ink2); font-weight: 700; font-size: 13.5px;
  padding: 8px 15px; border-radius: 10px; transition: all .2s;
}
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 5px rgba(0, 0, 0, .12); }

/* ---------- الحاوية ---------- */
main { max-width: 900px; margin: 0 auto; padding: 20px 16px 44px; }
.view { animation: viewIn .35s ease both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.view[hidden] { display: none; }
.pagehead { margin: 8px 4px 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagehead h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.pagehead p { color: var(--ink2); font-size: 14px; font-weight: 600; margin-top: 2px; }
.stats-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 99px;
  padding: 8px 18px; font-size: 13px; font-weight: 700; color: var(--ink2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}
.stats-pill b { color: var(--gold); font-size: 15px; }
.stats-pill .sep { width: 4px; height: 4px; background: var(--line); border-radius: 50%; }

/* ---------- البحث والفلترة ---------- */
.search {
  width: 100%; padding: 13px 18px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--card); outline: none; margin-bottom: 12px; font-weight: 600;
  box-shadow: var(--shadow); transition: all .2s;
}
.search:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(184, 147, 74, .13); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 6px; }
.chip-f {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card); border-radius: 99px;
  padding: 7px 15px; font-size: 13px; font-weight: 700; color: var(--ink2); transition: all .2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.chip-f.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- بطاقة المربع (مجمعة) ---------- */
.block-card {
  background: var(--card); border-radius: 22px; border: 1px solid var(--line);
  box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden;
}
.block-head {
  display: flex; align-items: center; gap: 12px; padding: 15px 20px 13px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0, 0, 0, .018), transparent);
}
.block-badge { min-width: 50px; text-align: center; padding: 6px 10px 5px; border-radius: 14px; }
.block-badge small { display: block; font-size: 9.5px; font-weight: 800; opacity: .85; line-height: 1.1; }
.block-badge b { font-size: 19px; line-height: 1.15; }
.block-range { font-size: 12.5px; font-weight: 700; color: var(--ink2); }
.block-head .line { flex: 1; height: 1px; background: var(--line); }
.block-head .dm { width: 7px; height: 7px; transform: rotate(45deg); border-radius: 2px; }

/* المالك: صف داخل بطاقة المربع */
.owner { display: flex; align-items: center; gap: 13px; padding: 13px 20px; border-bottom: 1px solid rgba(0, 0, 0, .045); transition: background .15s; }
.owner:last-child { border-bottom: none; }
.owner:hover { background: rgba(0, 0, 0, .02); }
.owner .avatar {
  width: 46px; height: 46px; border-radius: 15px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 6px rgba(0, 0, 0, .12);
}
.owner .info { flex: 1; min-width: 0; }
.owner .name { font-weight: 750; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.owner .meta { font-size: 12.5px; color: var(--ink2); font-weight: 700; display: flex; gap: 7px; margin-top: 3px; }
.owner .meta .v { background: rgba(0, 0, 0, .05); border-radius: 8px; padding: 1px 9px; }
.owner .phone { flex: 0 0 auto; text-align: center; font-weight: 800; font-feature-settings: 'tnum'; font-size: 14.5px; direction: ltr; }
.owner .phone a { display: inline-block; padding: 8px 13px; border-radius: 12px; background: rgba(52, 199, 89, .13); color: #1d8a43; transition: all .2s; }
.owner .phone a:active { transform: scale(.96); }
.owner .phone.hidden-note { color: var(--ink2); font-size: 11px; font-weight: 700; opacity: .75; }

/* ألوان المعادن */
.m-gold   { background: linear-gradient(135deg, #d9bc7d, #a8873f); color: #fff; }
.m-silver { background: linear-gradient(135deg, #c6cbd3, #8b93a0); color: #fff; }
.m-gun    { background: linear-gradient(135deg, #5d6f88, #37455a); color: #fff; }
.m-copper { background: linear-gradient(135deg, #cf8d5e, #9c5a2f); color: #fff; }
.soft-gold   { background: var(--gold-soft);   color: var(--gold); }
.soft-silver { background: var(--silver-soft); color: var(--silver); }
.soft-gun    { background: var(--gun-soft);    color: var(--gun); }
.soft-copper { background: var(--copper-soft); color: var(--copper); }

/* ---------- الفعاليات ---------- */
.event { position: relative; overflow: hidden; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 18px 22px 16px; margin-bottom: 14px; }
.event::before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, var(--gold), var(--copper)); }
.event h3 { font-size: 19px; font-weight: 800; margin-bottom: 8px; }
.event .row { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; color: var(--ink2); margin: 5px 0; }
.event .ico { width: 27px; height: 27px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .05); font-size: 13px; }
.event .imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; margin-top: 12px; }
.event .imgs img { width: 100%; height: 120px; object-fit: cover; border-radius: 14px; }
.event .links a { color: #0066cc; font-weight: 700; font-size: 14px; }
.empty { text-align: center; color: var(--ink2); padding: 44px 0; font-weight: 700; }

/* ---------- الإعلانات ---------- */
.ann { position: relative; overflow: hidden; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 17px 22px 15px; margin-bottom: 14px; }
.ann::before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 4px; }
.ann.t-ولادة::before { background: #34c759; }
.ann.t-وفاة::before  { background: #46566b; }
.ann.t-عام::before   { background: var(--gold); }
.ann.t-تهنئة::before { background: #c98a5e; }
.ann.t-تذكير::before { background: #9ba1ab; }
.ann .head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.ann .type { padding: 3px 13px; border-radius: 99px; font-size: 12px; font-weight: 800; }
.ann .ttl { font-size: 16.5px; font-weight: 800; flex: 1; }
.ann .body { font-size: 14.5px; font-weight: 600; color: #3d3d40; white-space: pre-wrap; line-height: 1.9; }
.ann .date { margin-top: 10px; font-size: 11.5px; color: var(--ink2); font-weight: 700; }

/* ---------- النماذج ---------- */
.form { max-width: 580px; margin: 0 auto; padding: 22px; border-radius: 22px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13.5px; font-weight: 750; margin-bottom: 7px; }
.field label .req { color: #d02f2f; }
.field label .opt { color: var(--ink2); font-weight: 650; font-size: 11.5px; }
.field input {
  width: 100%; padding: 14px 16px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--card); outline: none; font-weight: 650; transition: all .2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(184, 147, 74, .14); }
select.sel {
  width: 100%; padding: 13px 15px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--card); outline: none; font-weight: 700; transition: all .2s;
}
select.sel:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(184, 147, 74, .14); }

/* شارات الاسم */
.type-pill {
  display: inline-block; padding: 1.5px 9px; border-radius: 99px;
  font-size: 10.5px; font-weight: 800; vertical-align: middle; margin-right: 7px;
  position: relative; top: -1px;
}
.tp-owner { background: var(--gold-soft); color: var(--gold); }
.tp-tenant { background: rgba(0, 122, 255, .13); color: #0066cc; }
[data-theme="dark"] .tp-tenant { background: rgba(80, 150, 255, .18); color: #7ab8ff; }
.role-badge {
  display: inline-block; padding: 2px 11px; border-radius: 99px;
  font-size: 11px; font-weight: 800; vertical-align: middle; margin-right: 5px;
  background: linear-gradient(135deg, rgba(201, 169, 97, .2), rgba(201, 169, 97, .08));
  color: var(--gold); border: 1px solid rgba(184, 147, 74, .4);
}
[data-theme="dark"] .role-badge { color: #d9c08a; }

/* المناصب */
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 13px; }
.role-card {
  display: flex; align-items: center; gap: 15px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 17px 18px; box-shadow: var(--shadow);
}
.r-ico {
  width: 54px; height: 54px; border-radius: 17px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 27px;
  background: linear-gradient(135deg, var(--gold-soft), rgba(184, 147, 74, .08));
  border: 1px solid rgba(184, 147, 74, .3);
}
.r-title { font-weight: 800; font-size: 15.5px; }
.r-holder { font-size: 13.5px; font-weight: 750; margin-top: 2px; }
.r-villa { font-size: 11.5px; color: var(--ink2); font-weight: 700; margin-top: 2px; }
.quick-emoji { display: flex; gap: 6px; margin: 6px 0 10px; flex-wrap: wrap; }
.qe {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  width: 38px; height: 38px; font-size: 18px; transition: all .2s;
}
.qe:hover { border-color: var(--gold); }
.hint { font-size: 12px; color: var(--ink2); margin-top: 5px; font-weight: 600; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}
.switch-row .lbl { font-weight: 750; font-size: 14px; }
.switch-row .sub { font-size: 11.5px; color: var(--ink2); font-weight: 650; }
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: rgba(0, 0, 0, .16); border-radius: 99px; transition: .25s; cursor: pointer; }
.switch .track::after {
  content: ''; position: absolute; top: 2px; right: 2px; width: 27px; height: 27px;
  background: var(--card); border-radius: 50%; transition: .25s; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.switch input:checked + .track { background: #c9a961; }
.switch input:checked + .track::after { transform: translateX(-20px); }

.warn {
  max-width: 580px; margin: 0 auto 14px; padding: 12px 16px; border-radius: 16px;
  background: rgba(255, 159, 10, .12); color: #9a6700;
  font-size: 13px; font-weight: 750; line-height: 1.7;
  border: 1px solid rgba(255, 159, 10, .35);
}
[data-theme="dark"] .warn { color: #ffc94d; background: rgba(255, 159, 10, .08); }
.btn {
  width: 100%; padding: 15px; border: 0; border-radius: 16px;
  background: linear-gradient(135deg, #d6b877, #a8873f); color: #fff;
  font-size: 16.5px; font-weight: 800; transition: opacity .2s, transform .1s;
  box-shadow: 0 4px 14px rgba(168, 135, 63, .35);
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; }
.msg { max-width: 580px; margin: 0 auto 14px; padding: 14px 17px; border-radius: 16px; font-weight: 750; font-size: 14px; display: none; }
.msg.ok { display: block; background: rgba(52, 199, 89, .14); color: #1d8a43; }
.msg.err { display: block; background: rgba(255, 59, 48, .1); color: #c0271d; }

/* ---------- شريط الجوال السفلي ---------- */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; display: none;
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--line);
}
.bottombar .inner { max-width: 640px; margin: 0 auto; display: flex; }
.btab {
  flex: 1; border: 0; background: transparent; padding: 9px 0 11px; text-align: center;
  color: var(--ink2); font-weight: 700; font-size: 10px;
}
.btab .ic { display: block; font-size: 19px; line-height: 1.3; }
.btab.active { color: var(--gold); }

/* ---------- الإدارة ---------- */
.gate { max-width: 380px; margin: 60px auto; text-align: center; padding: 28px 24px; }
.gate h1 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: 16px; border: 1px solid var(--line); padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.stat b { font-size: 24px; display: block; color: var(--gold); }
.stat span { font-size: 12px; color: var(--ink2); font-weight: 750; }
.tablewrap { overflow-x: auto; background: var(--card); border-radius: var(--r); border: 1px solid var(--line); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
th { background: rgba(0, 0, 0, .04); font-weight: 800; padding: 11px 13px; text-align: right; white-space: nowrap; }
td { padding: 10px 13px; border-top: 1px solid var(--line); white-space: nowrap; }
.badge { display: inline-block; padding: 2px 11px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.badge.on { background: rgba(52, 199, 89, .14); color: #1d8a43; }
.badge.off { background: rgba(255, 59, 48, .1); color: #c0271d; }
.badge.pend { background: rgba(255, 159, 10, .16); color: #9a6700; }
.rowact { display: flex; gap: 6px; }
.sbtn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 12px; font-size: 12.5px; font-weight: 750; }
.sbtn.danger { color: #c0271d; border-color: rgba(192, 39, 29, .3); }
.sbtn.ok { color: #1d8a43; border-color: rgba(29, 138, 67, .3); }
.admin-tabs { display: flex; gap: 7px; margin-bottom: 16px; flex-wrap: wrap; }
.ata { border: 1px solid var(--line); background: var(--card); border-radius: 13px; padding: 10px 17px; font-weight: 800; font-size: 13.5px; color: var(--ink2); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.ata.active { background: var(--ink); color: #fff; border-color: var(--ink); }
textarea {
  width: 100%; min-height: 120px; padding: 13px 16px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--card); outline: none; font-weight: 650;
}
textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(184, 147, 74, .14); }
.event-admin { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 13px 16px; margin-bottom: 9px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.event-admin .t { flex: 1; font-weight: 750; }
.event-admin .t small { display: block; color: var(--ink2); font-weight: 650; }

/* ---------- الجوال ---------- */
@media (max-width: 640px) {
  .bottombar { display: block; }
  .tabs { display: none; }
  .topbar-inner { justify-content: center; }
  body { padding-bottom: 84px; }
  main { padding: 14px 12px 30px; }
  .pagehead h1 { font-size: 24px; }
  .owner { padding: 12px 15px; gap: 11px; }
  .owner .phone a { padding: 7px 10px; font-size: 13px; }
}
@media (min-width: 641px) { .bottombar { display: none; } }

/* ---------- تعريفات الوضع الليلي: النصوص والخلفيات الدقيقة ---------- */
[data-theme="dark"] .event .body,
[data-theme="dark"] .ann .body { color: #c9cdd4; }
[data-theme="dark"] .msg.ok { color: #4ade80; }
[data-theme="dark"] .msg.err { color: #f87171; }
[data-theme="dark"] .owner .phone a { color: #4ade80; }
[data-theme="dark"] .switch .track { background: rgba(255, 255, 255, .22); }
[data-theme="dark"] .owner .meta .v,
[data-theme="dark"] .event .ico { background: rgba(255, 255, 255, .09); }
[data-theme="dark"] thead th { background: rgba(255, 255, 255, .06); }
[data-theme="dark"] .owner:hover { background: rgba(255, 255, 255, .03); }
[data-theme="dark"] .block-head { background: none; }
[data-theme="dark"] .badge.on { color: #4ade80; }
[data-theme="dark"] .badge.off { color: #f87171; }
[data-theme="dark"] .badge.pend { color: #ffc94d; }
[data-theme="dark"] .r-ico { background: rgba(201, 169, 97, .12); border-color: rgba(184, 147, 74, .35); }


/* ---------- النافذة المنبثقة (ستايل أبل) ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-back[hidden] { display: none; }
.modal {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  background: var(--card); border-radius: 22px; border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
  animation: modalIn .25s ease both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 17px; font-weight: 800; }
.modal-x {
  border: 0; background: rgba(0, 0, 0, .06); color: var(--ink2);
  width: 30px; height: 30px; border-radius: 50%; font-size: 13px; cursor: pointer;
}
[data-theme="dark"] .modal-x { background: rgba(255, 255, 255, .08); }
.modal-body { padding: 16px 20px 4px; }
.modal-foot { display: flex; gap: 10px; align-items: center; padding: 14px 20px 18px; }
