/* ============ لوحة التحكم ============ */
:root {
  --navy: #0A0F1F; --navy-2: #141B31; --navy-3: #2C3D6B;
  --gold: #E2B85C; --gold-2: #F3D58E;
  --cream: #F4F2EC; --line: #E2DED3; --muted: #5B6478;
  --danger: #A3312A;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; background: var(--cream); color: var(--navy); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; line-height: 1.3; }
p { margin: 0; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.link { color: #7A5A12; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 16px; align-self: flex-start;
  width: 270px; flex: none; height: calc(100vh - 32px); margin: 16px;
  background: var(--navy); color: #fff; border-radius: 28px;
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
  animation: slideIn .7s var(--ease) both;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.side-brand strong { display: block; font-size: 19px; font-weight: 600; }
.side-brand small { color: var(--gold-2); font-size: 13px; }
.logo-ring { position: relative; width: 54px; height: 54px; flex: none; display: grid; place-items: center; }
.logo-ring img { width: 38px; position: relative; z-index: 1; }
.logo-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--gold), transparent 35%, var(--gold-2) 55%, transparent 80%, var(--gold));
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 64%); mask: radial-gradient(circle, transparent 62%, #000 64%);
  animation: spin 6s linear infinite;
}
.logo-ring.big { width: 96px; height: 96px; margin: 0 auto; }
.logo-ring.big img { width: 66px; }
@keyframes spin { to { transform: rotate(360deg); } }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 999px;
  color: #C8CEDD; transition: background .3s, color .3s, transform .4s var(--ease);
}
.side-nav a:hover { background: var(--navy-2); color: #fff; transform: translateX(-4px); }
.side-nav a svg { transition: transform .6s var(--bounce); }
.side-nav a:hover svg { transform: rotate(-15deg) scale(1.1); }
.side-nav a.is-active { background: var(--gold); color: var(--navy); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-btn { padding: 12px; border-radius: 999px; border: 1px solid var(--navy-3); text-align: center; transition: background .3s, border-color .3s; }
.side-btn:hover { background: var(--navy-2); border-color: var(--gold); }
.side-btn.ghost { border-color: transparent; color: #A9B1C6; }

.main { flex: 1; min-width: 0; padding: 32px 32px 48px 16px; display: flex; flex-direction: column; gap: 22px; }
.main > * { animation: rise .6s var(--ease) both; }
.main > *:nth-child(2) { animation-delay: .05s; } .main > *:nth-child(3) { animation-delay: .1s; } .main > *:nth-child(4) { animation-delay: .15s; } .main > *:nth-child(5) { animation-delay: .2s; }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.page-head h1 { font-size: 36px; font-weight: 600; letter-spacing: -.5px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* buttons */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 500; cursor: pointer; background: transparent;
  transition: transform .35s var(--ease), box-shadow .35s, background .3s, color .3s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(.97); }
.btn::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%); transform: translateX(120%); transition: transform .7s var(--ease); }
.btn:hover::after { transform: translateX(-120%); }
.btn.gold { background: var(--gold); color: var(--navy); font-weight: 600; }
.btn.gold:hover { box-shadow: 0 12px 26px -10px rgba(226,184,92,.8); }
.btn.dark { background: var(--navy); color: #fff; font-weight: 600; }
.btn.outline { border-color: var(--navy); color: var(--navy); }
.btn.outline:hover { background: var(--navy); color: #fff; }
.btn.sm { min-height: 40px; padding: 0 16px; font-size: 14px; }
.btn.full { width: 100%; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  display: inline-grid; place-items: center; cursor: pointer; font-size: 16px;
  transition: transform .5s var(--bounce), background .3s, color .3s, border-color .3s;
}
.icon-btn:hover:not(:disabled) { transform: rotate(-12deg) scale(1.08); background: var(--navy); color: #fff; border-color: var(--navy); }
.icon-btn.danger { color: var(--danger); border-color: #F0D4D2; }
.icon-btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-actions form { margin: 0; }

/* cards */
.card { background: #fff; border-radius: 28px; padding: 24px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h2, .form-card h2 { font-size: 21px; font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat { background: #fff; border-radius: 26px; padding: 22px 24px; display: flex; flex-direction: column; gap: 4px; transition: transform .5s var(--ease); }
.stat:hover { transform: translateY(-5px) rotate(-1deg); }
.stat span { font-size: 14px; color: var(--muted); }
.stat strong { font-size: 42px; font-weight: 600; line-height: 1.2; }
.stat.dark { background: var(--navy); color: #fff; } .stat.dark span { color: #A9B1C6; }
.stat.gold { background: var(--gold); } .stat.gold span { color: #3A2E10; }

.cat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.cat-mini { border: 1px solid var(--line); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 4px; transition: transform .5s var(--ease), border-color .3s, background .3s, color .3s; }
.cat-mini:hover { transform: translateY(-4px); background: var(--navy); color: #fff; border-color: var(--navy); }
.cat-mini .ic, .cat-item .ic { width: 46px; height: 46px; border-radius: 50%; background: var(--cream); color: var(--navy); display: grid; place-items: center; margin-bottom: 8px; transition: transform .7s var(--bounce), background .3s; }
.cat-mini:hover .ic { transform: rotate(360deg); background: var(--gold); }
.cat-mini small { color: var(--muted); } .cat-mini:hover small { color: var(--gold-2); }

.cat-list { display: flex; flex-direction: column; gap: 10px; }
.cat-item { background: #fff; border-radius: 24px; padding: 16px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; transition: box-shadow .4s, transform .4s var(--ease); }
.cat-item:hover { box-shadow: 0 16px 30px -22px rgba(10,15,31,.5); transform: translateY(-2px); }
.cat-item .ic { margin: 0; }
.cat-item:hover .ic { transform: rotate(-20deg); background: var(--gold); }
.cat-item strong { display: block; font-size: 18px; font-weight: 600; }
.grow { flex: 1 1 220px; min-width: 0; }

/* tabs & pills */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab { padding: 10px 18px; border-radius: 999px; background: #fff; font-weight: 500; transition: background .3s, color .3s, transform .3s var(--ease); }
.tab span { display: inline-block; min-width: 24px; padding: 0 6px; margin-inline-start: 6px; border-radius: 999px; background: var(--cream); font-size: 13px; text-align: center; }
.tab:hover { transform: translateY(-2px); }
.tab.is-active { background: var(--navy); color: #fff; } .tab.is-active span { background: var(--gold); color: var(--navy); }
.pills { display: flex; gap: 4px; padding: 5px; border-radius: 999px; background: var(--cream); }
.pill { min-height: 40px; padding: 0 18px; border-radius: 999px; display: inline-flex; align-items: center; font-size: 14px; font-weight: 500; transition: background .3s, color .3s; }
.pill.is-active { background: var(--navy); color: #fff; }

/* table */
.table-wrap { overflow-x: auto; margin: 0 -24px -24px; }
table { width: 100%; min-width: 720px; border-collapse: collapse; text-align: right; }
th { background: #FAF9F5; color: var(--muted); font-weight: 500; font-size: 14px; padding: 14px 18px; }
th:first-child, td:first-child { padding-inline-start: 24px; }
td { padding: 12px 18px; border-top: 1px solid #F0EDE5; }
tbody tr { transition: background .25s; }
tbody tr:hover { background: #FBFAF6; }
.cell-proj { display: flex; align-items: center; gap: 12px; }
.cell-proj img, .cell-proj .ph { width: 52px; height: 52px; border-radius: 14px; object-fit: cover; background: #ECE9E0; flex: none; transition: transform .5s var(--ease); }
tbody tr:hover .cell-proj img { transform: scale(1.1) rotate(-3deg); }
.badge { padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; background: #E7EBF5; white-space: nowrap; }
.badge.cur { background: #FBF1D9; color: #7A5A12; }

/* forms */
.form-card { display: flex; flex-direction: column; gap: 18px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; color: #3D4660; }
.field-label { display: block; font-size: 14px; font-weight: 500; color: #3D4660; margin-bottom: 8px; }
input:not([type=radio]):not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: #fff;
  padding: 10px 14px; font-weight: 400; color: var(--navy);
  transition: border-color .25s, box-shadow .25s;
}
textarea { resize: vertical; line-height: 1.8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(226,184,92,.22); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.grid-2.align-start { align-items: start; gap: 22px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-form label:not(.grow) { min-width: 180px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.seg { border: 0; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.seg legend { font-size: 14px; font-weight: 500; color: #3D4660; margin-bottom: 8px; padding: 0; }
.seg-opt { flex-direction: row; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; }
.seg-opt span { min-height: 46px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--line); display: inline-flex; align-items: center; transition: background .3s, color .3s, border-color .3s; }
.seg-opt input:checked + span { background: var(--navy); color: #fff; border-color: var(--navy); }
.seg-opt input:focus-visible + span { box-shadow: 0 0 0 4px rgba(226,184,92,.35); }

.drop {
  position: relative; align-items: center; text-align: center; gap: 6px;
  border: 2px dashed var(--line); border-radius: 22px; padding: 26px; cursor: pointer; color: var(--muted);
  transition: border-color .3s, background .3s;
}
.drop:hover { border-color: var(--gold); background: #FFFBF1; }
.drop svg { transition: transform .5s var(--bounce); }
.drop:hover svg { transform: translateY(-5px); }
.drop strong { color: var(--navy); }
.drop input, .file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn { position: relative; align-self: flex-start; }
.img-preview, .img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.img-preview:empty { display: none; }
.img-preview img { width: 100%; height: 100px; object-fit: cover; border-radius: 14px; animation: rise .4s var(--ease) both; }
.img-tile { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; }
.img-tile img { height: 110px; width: 100%; object-fit: cover; }
.tile-opt { flex-direction: row; align-items: center; gap: 6px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.tile-opt.danger { color: var(--danger); border-top: 1px solid #F0EDE5; }

.logo-edit { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.logo-box { width: 150px; height: 150px; border-radius: 26px; background: var(--navy); display: grid; place-items: center; padding: 18px; }
.logo-box img { max-height: 110px; object-fit: contain; transition: transform .8s var(--bounce); }
.logo-box:hover img { transform: rotate(360deg); }
.hero-edit { height: 220px; border-radius: 22px; overflow: hidden; background: #ECE9E0; }
.hero-edit img { width: 100%; height: 100%; object-fit: cover; }

/* toast */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 99;
  padding: 14px 24px; border-radius: 999px; background: var(--navy); color: #fff; font-weight: 500;
  box-shadow: 0 20px 40px -16px rgba(10,15,31,.6);
  animation: toastIn .6s var(--bounce) both !important;
  transition: opacity .5s, transform .5s;
}
.toast.is-out { opacity: 0; transform: translate(-50%, -20px); }
@keyframes toastIn { from { transform: translate(-50%, -40px); opacity: 0; } }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: var(--navy); padding: 24px; overflow: hidden; position: relative; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); }
.orb-a { width: 460px; height: 460px; background: #2A3A78; top: -120px; right: -100px; animation: drift 16s ease-in-out infinite alternate; }
.orb-b { width: 380px; height: 380px; background: rgba(226,184,92,.4); bottom: -140px; left: -80px; animation: drift 20s ease-in-out infinite alternate-reverse; }
@keyframes drift { to { transform: translate(-80px, 60px) scale(1.15); } }
.glass { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.login { position: relative; width: min(420px, 100%); border-radius: 32px; padding: 36px 30px; color: #fff; display: flex; flex-direction: column; gap: 16px; text-align: center; animation: rise .8s var(--ease) both; }
.login h1 { font-size: 28px; font-weight: 600; margin-top: 6px; }
.login p { color: #A9B1C6; margin-top: -10px; }
.login label { color: #C8CEDD; text-align: right; }
.login input { background: rgba(255,255,255,.92) !important; }
.login .back { color: #A9B1C6; font-size: 14px; }
.alert { padding: 12px; border-radius: 14px; background: rgba(163,49,42,.25); border: 1px solid rgba(255,120,110,.4); }

/* responsive */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .side { position: static; width: auto; height: auto; margin: 12px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { flex-direction: row; }
  .side-foot a { flex: 1; }
  .main { padding: 8px 16px 40px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============ المسلسلات والشقق ============ */
.small { font-size: 13px; }
.t-av { color: #1E7A4C; }
.t-sold { color: #9A3B32; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.check { flex-direction: row; align-items: center; gap: 8px; min-height: 46px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }
.serials-card { scroll-margin-top: 20px; }
.serials-card .card-head p { margin-top: 4px; }
.add-serial { margin-bottom: 18px; }
.add-serial > summary { list-style: none; display: inline-flex; }
.add-serial > summary::-webkit-details-marker { display: none; }
.add-serial[open] > summary { margin-bottom: 14px; }
.add-serial-form { background: #FAF9F5; border: 1px solid var(--line); border-radius: 22px; padding: 20px; animation: rise .5s var(--ease) both; }

.serial-list { display: flex; flex-direction: column; gap: 16px; }
.serial { border: 1px solid var(--line); border-radius: 26px; padding: 18px; background: #fff; transition: box-shadow .4s, border-color .4s; }
.serial:hover { box-shadow: 0 18px 36px -26px rgba(10,15,31,.55); border-color: #D6CFBE; }
.serial-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.serial-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.serial-title strong { display: block; font-size: 18px; font-weight: 600; }
.serial-no {
  width: 58px; height: 64px; border-radius: 999px 999px 14px 14px; background: var(--navy); color: var(--gold);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  font-family: 'El Messiri', serif; font-size: 24px; font-weight: 700;
}
.serial-no small { font-size: 10px; color: #A9B1C6; font-family: inherit; font-weight: 400; margin-bottom: 4px; }
.avail-pill { padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: background .3s, color .3s; }
.avail-pill.is-av { background: #E3F4EA; color: #1E7A4C; }
.avail-pill.is-sold { background: #F6E3E1; color: #9A3B32; }

.building { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 20px; background: linear-gradient(#F7F5EF, #EFEBE1); position: relative; }
.building::after { content: ""; display: block; height: 6px; border-radius: 6px; background: var(--navy); margin-top: 4px; }
.floor-row { display: flex; align-items: center; gap: 10px; }
.floor-name { flex: 0 0 110px; font-size: 13px; font-weight: 600; color: #3D4660; }
.floor-units { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.floor-units form, .floor-row > form { margin: 0; }
.unit {
  min-width: 108px; min-height: 64px; padding: 8px 12px; border-radius: 14px; border: 1.5px solid transparent;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; cursor: pointer; text-align: right; position: relative;
  transition: transform .35s var(--bounce), background .3s, border-color .3s, color .3s, opacity .2s;
}
.unit span { font-weight: 600; font-size: 14px; }
.unit small { font-size: 12px; opacity: .8; }
.unit em { position: absolute; top: 8px; left: 10px; font-style: normal; font-size: 11px; font-weight: 600; }
.unit.is-av { background: #E3F4EA; border-color: #9ED3B3; color: #145A37; }
.unit.is-sold { background: #ECEAE4; border-color: #DAD6CC; color: #7C7F8A; }
.unit.is-sold span { text-decoration: line-through; }
.unit:hover { transform: translateY(-3px); }
.unit.is-busy { opacity: .5; }
.unit.flip { animation: flip .5s var(--ease); }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.unit-add { width: 44px; min-height: 64px; border-radius: 14px; border: 1.5px dashed #C9C2B0; background: transparent; color: #7C7F8A; font-size: 20px; cursor: pointer; transition: border-color .3s, color .3s, transform .3s var(--bounce); }
.unit-add:hover { border-color: var(--navy); color: var(--navy); transform: rotate(90deg); }
.sm-x { width: 34px; height: 34px; font-size: 18px; }
.serial-more { margin-top: 14px; }
.serial-more summary { cursor: pointer; color: #7A5A12; font-weight: 500; font-size: 14px; }
.serial-more[open] summary { margin-bottom: 12px; }
.area-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 12px; }
.area-grid label { font-size: 12px; }
.area-input.saved { border-color: #1E7A4C !important; box-shadow: 0 0 0 4px rgba(30,122,76,.15) !important; }
@media (max-width: 700px) { .floor-row { flex-wrap: wrap; } .floor-name { flex-basis: 100%; } }
.page-head h1, .card-head h2, .form-card h2, .side-brand strong, .stat strong, .login h1, .cat-item strong { font-family: 'El Messiri', serif; }
.page-head h1 { font-size: 38px; font-weight: 700; letter-spacing: 0; }
