/* Layout: header bar, single centered column, card grids. Palette from Nile water + limestone. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #17282b;
  --muted: #5d6e70;
  --line: #e2ddd2;
  --brand: #0e5a63;
  --brand-ink: #ffffff;
  --accent: #f2c46d;
  --accent-ink: #2b2004;
  --good: #1f7a4d;
  --danger: #b3261e;
  --chip: #ebe6da;
  --shadow: 0 1px 2px rgba(23,40,43,.06), 0 6px 20px rgba(23,40,43,.06);
  --display: "Reem Kufi", "Tajawal", system-ui, sans-serif;
  --body: "Tajawal", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a1c; --surface: #16262a; --ink: #e8efee; --muted: #9fb2b3; --line: #26393d;
    --brand: #4fb3bd; --brand-ink: #062226; --accent: #f2c46d; --accent-ink: #2b2004;
    --good: #5cc48f; --danger: #ff8a80; --chip: #1f3236;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.6; }
img { max-width: 100%; display: block; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--display); line-height: 1.3; text-wrap: balance; margin: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.num { font-variant-numeric: tabular-nums; }

.site-header { background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 20; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark svg { width: 34px; height: 34px; fill: var(--accent); }
.brand-mark rect { fill: var(--brand); }
.brand-text { font-family: var(--display); font-size: 1.3rem; display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font-family: var(--body); font-size: .75rem; opacity: .85; }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav a:not(.btn) { color: inherit; text-decoration: none; font-weight: 500; }
@media (max-width: 560px) { .nav a:not(.btn) { display: none; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 10px 18px; font: 700 1rem var(--body); cursor: pointer; text-decoration: none; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-brand { background: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-wa { background: #1f9d55; color: #fff; }
.btn[disabled] { opacity: .6; cursor: progress; }

main { padding-block: 24px 48px; display: flex; flex-direction: column; gap: 36px; min-height: 60vh; }

.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(20px, 4vw, 40px); display: grid; gap: 18px; box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); }
.hero p { margin: 0; color: var(--muted); font-size: 1.1rem; max-width: 60ch; }
.notice { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, var(--ink)); border-radius: 14px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; justify-content: space-between; }
.notice p { margin: 0; color: var(--ink); max-width: 70ch; }
.notice strong { display: block; font-size: 1.05rem; }

.search { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: .95rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
textarea { min-height: 120px; resize: vertical; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { font-size: 1.5rem; }
.section-head p { margin: 0; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-img { aspect-ratio: 4 / 3; background: var(--chip); position: relative; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-img .pill { position: absolute; top: 10px; right: 10px; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.price { font-family: var(--display); font-size: 1.35rem; color: var(--brand); }
.loc { color: var(--muted); font-weight: 500; }
.specs { display: flex; gap: 12px; color: var(--muted); font-size: .9rem; flex-wrap: wrap; }
.summary { margin: 0; font-size: .95rem; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.source { font-size: .8rem; color: var(--muted); margin-top: auto; }
.card .btn { margin-top: 6px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--brand); color: var(--brand-ink); }
.pill.rent { background: var(--accent); color: var(--accent-ink); }
.badge-direct { display: inline-flex; align-items: center; gap: 6px; background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--good); font-weight: 700; font-size: .85rem; padding: 3px 10px; border-radius: 999px; width: fit-content; }

.fallback-img { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--accent))); color: var(--brand-ink); font-family: var(--display); text-align: center; padding: 12px; }
.fallback-img b { font-size: 1.3rem; }

.govs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gov { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-decoration: none; color: var(--ink); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.gov:hover { border-color: var(--brand); color: var(--brand); }
.gov.featured { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); grid-column: span 2; font-size: 1.15rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--chip); color: var(--ink); border-radius: 999px; padding: 6px 14px; text-decoration: none; font-size: .95rem; border: 1px solid transparent; }
.chip.active { background: var(--brand); color: var(--brand-ink); }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; padding: 28px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }

.form { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: clamp(16px, 3vw, 28px); display: grid; gap: 16px; max-width: 760px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; flex-direction: row; justify-content: center; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; }
.seg label:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--brand); font-weight: 700; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.thumbs img { aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.hint { color: var(--muted); font-size: .88rem; margin: 0; }
.error { color: var(--danger); font-weight: 700; margin: 0; }

.detail { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }
.gallery-main { aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: var(--chip); }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.gallery-thumbs button { border: 2px solid transparent; padding: 0; border-radius: 8px; overflow: hidden; width: 76px; height: 60px; flex: none; cursor: pointer; background: none; }
.gallery-thumbs button.on { border-color: var(--brand); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 12px; }
.phone { font-size: 1.5rem; font-weight: 800; letter-spacing: .04em; direction: ltr; text-align: right; user-select: all; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 700; }
.desc { white-space: pre-line; margin: 0; }

.prose { max-width: 70ch; display: grid; gap: 12px; }
.prose p, .prose li { color: var(--ink); }
.steps { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; }
.steps li::before { content: counter(s); font-family: var(--display); background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 30px; height: 30px; flex: none; display: grid; place-items: center; }

table.admin { width: 100%; border-collapse: collapse; background: var(--surface); }
table.admin th, table.admin td { padding: 8px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; font-size: .92rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }

.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding-block: 24px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.footer-brand { font-family: var(--display); font-size: 1.1rem; }
.site-footer p { margin: 6px 0; color: var(--muted); }
.fine { font-size: .88rem; }

.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 12px; font-weight: 700; z-index: 50; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.skeleton { background: linear-gradient(90deg, var(--chip), var(--surface), var(--chip)); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 14px; min-height: 280px; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .card { transition: none; } }
