/* Miftah Realty: tokens, layout and shared components. Page files add their own prefixed rules. */
:root {
  --paper: #F7F3EC;        /* page */
  --surface: #FFFFFF;      /* cards, inputs */
  --sunk: #EFE9DD;         /* quiet panels, table heads */
  --line: #E0D8C9;
  --ink: #1D2A26;          /* text */
  --ink-soft: #5C6762;
  --pine: #17332D;         /* header, footer, dark bands */
  --pine-2: #224339;
  --brass: #A67B2B;        /* the one accent: a brass key */
  --brass-deep: #84601C;
  --brass-tint: #F3E8D2;
  --ok: #2C6A4D;  --ok-tint: #E2F0E8;
  --warn: #9A5B12; --warn-tint: #F8EBD3;
  --bad: #A2372B;  --bad-tint: #F7E1DD;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(29, 42, 38, .06), 0 8px 24px rgba(29, 42, 38, .06);
  --gutter: clamp(16px, 4vw, 40px);
  --display: "El Messiri", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --text: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100svh; display: flex; flex-direction: column; background: var(--paper); color: var(--ink); font: 400 1rem/1.75 var(--text); -webkit-font-smoothing: antialiased; }
html[dir="ltr"] body { line-height: 1.6; }
main { flex: 1; outline: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.25; margin: 0 0 .5em; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h2 { font-size: clamp(1.45rem, 2.6vw, 2rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(32px, 6vw, 72px); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.section-head h2 { margin: 0; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.loading { padding-block: 80px; text-align: center; color: var(--ink-soft); }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-soft); }
.empty h1, .empty h2, .empty h3 { color: var(--ink); }
.skip { position: absolute; inset-inline-start: 16px; top: -60px; z-index: 50; background: var(--pine); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }

/* Header */
.site-header { background: var(--pine); color: #F4EFE4; position: sticky; top: 0; z-index: 20; }
.header-row { display: flex; align-items: center; gap: 12px 28px; flex-wrap: wrap; padding-block: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1.35rem/1 var(--display); text-decoration: none; color: inherit; }
.brand-mark { width: 26px; height: 26px; color: var(--brass); flex: none; }
.site-header .brand-mark { color: #D9B466; }
.main-nav { display: flex; gap: 4px; margin-inline-end: auto; overflow-x: auto; scrollbar-width: none; }
.main-nav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; white-space: nowrap; font-size: .95rem; color: #D5D9D2; }
.main-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.main-nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .14); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: .9rem; color: #D5D9D2; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-header .btn-ghost { color: #F4EFE4; border-color: rgba(255, 255, 255, .28); }
.site-header .btn-ghost:hover { background: rgba(255, 255, 255, .1); }
@media (max-width: 720px) {
  .main-nav { order: 3; flex-basis: 100%; margin-inline: -6px; }
  .header-actions { margin-inline-start: auto; }
  .user-name { display: none; }
}

/* Footer */
.site-footer { background: var(--pine); color: #D5D9D2; margin-top: 48px; }
.footer-row { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-block: 32px; }
.site-footer .muted { color: #AEB8B1; margin: 8px 0 0; max-width: 44ch; }
.brand-footer { color: #F4EFE4; }
.site-footer .brand-mark { color: #D9B466; }
.footer-facts { display: flex; gap: 28px; flex-wrap: wrap; margin: 0; }
.footer-facts dt { font-size: .8rem; color: #AEB8B1; }
.footer-facts dd { margin: 0; font-variant-numeric: tabular-nums; color: #F4EFE4; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 20px; border: 1px solid transparent; border-radius: 999px; background: none; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brass); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brass-deep); }
.btn-dark { background: var(--pine); color: #fff; }
.btn-dark:hover:not(:disabled) { background: var(--pine-2); }
.btn-ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--sunk); }
.btn-danger { border-color: #E3B9B2; color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad-tint); }
.btn-sm { min-height: 36px; padding: 4px 14px; font-size: .9rem; }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--brass-deep); font-weight: 500; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--sunk); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--line); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 500; line-height: 1.7; white-space: nowrap; background: var(--brass-tint); color: var(--brass-deep); }
.chip-muted { background: var(--sunk); color: var(--ink-soft); }
.chip-ok { background: var(--ok-tint); color: var(--ok); }
.chip-warn { background: var(--warn-tint); color: var(--warn); }
.chip-bad { background: var(--bad-tint); color: var(--bad); }
.chip-dark { background: var(--pine); color: #fff; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: clamp(16px, 2.5vw, 24px); }
.panel { background: var(--sunk); border-radius: var(--radius); padding: clamp(16px, 2.5vw, 24px); }

/* Key / value lists */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 24px; margin: 0; }
.kv dt { font-size: .82rem; color: var(--ink-soft); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* Forms */
.field { display: grid; gap: 6px; }
.field label, .field legend { font-size: .9rem; font-weight: 500; }
.field small { font-size: .82rem; }
input, select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brass); outline-offset: 0; border-color: var(--brass); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--brass); }
.check { display: flex; align-items: center; gap: 10px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
/* Pickable options (time slots, financing): <label class="choice"><input type="radio">text</label> */
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 4px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-variant-numeric: tabular-nums; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice:has(input:checked) { background: var(--pine); border-color: var(--pine); color: #fff; }
.choice:has(input:focus-visible) { outline: 3px solid var(--brass); outline-offset: 2px; }
.choice:has(input:disabled) { opacity: .45; text-decoration: line-through; cursor: not-allowed; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 12px 14px; text-align: start; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table th { background: var(--sunk); font-weight: 600; font-size: .85rem; white-space: nowrap; color: var(--ink-soft); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: end; }

/* Tabs: <nav class="tabs"><a aria-current="page">…</a><a>…</a></nav> or buttons with aria-selected */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 24px; scrollbar-width: none; }
.tabs a, .tabs button { padding: 10px 16px; border: 0; border-bottom: 3px solid transparent; background: none; text-decoration: none; white-space: nowrap; color: var(--ink-soft); font-weight: 500; cursor: pointer; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a[aria-current="page"], .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brass); }

/* Modal (native dialog) */
dialog.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100svh - 24px); padding: clamp(18px, 3vw, 28px); border: 0; border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); overflow-y: auto; }
dialog.modal::backdrop { background: rgba(23, 51, 45, .55); }
.modal-x { position: absolute; inset-inline-end: 14px; top: 14px; margin: 0; }
.modal-title { margin: 0 48px 18px 0; font-size: 1.4rem; }
html[dir="ltr"] .modal-title { margin: 0 0 18px 0; padding-inline-end: 48px; }

/* Toasts */
#toast-root { position: fixed; inset-inline: 0; bottom: 20px; z-index: 100; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding-inline: 16px; }
.toast { max-width: 520px; padding: 10px 18px; border-radius: 12px; background: var(--pine); color: #fff; box-shadow: var(--shadow); }
.toast-bad { background: var(--bad); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
