@font-face { font-family: 'Jannat LT'; src: url('assets/jannat.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Jannat LT'; src: url('assets/jannat-bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --black: #000;
  --ink: #1d1a18;
  --ink-2: #5e554f;
  --ink-3: #8e847c;
  --umber: #843D21;
  --umber-600: #6c311a;
  --umber-50: #f3e4dc;
  --beige: #CDAC81;
  --beige-50: #f1e6d7;
  --green: #CEDEBD;
  --green-ink: #3f5a2c;
  --sugar: #F7F0EC;
  --paper: #fffdfb;
  --line: #e7dcd3;
  --line-2: #d8c9bc;
  --danger: #a3261b;
  --danger-50: #f8e1de;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(60, 35, 20, .06), 0 4px 16px rgba(60, 35, 20, .06);
  --font: 'Jannat LT', 'Segoe UI', Tahoma, 'Geeza Pro', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--sugar); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--umber); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ---------- boot / login ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-logo { width: 180px; opacity: .8; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-card img { width: 170px; display: block; margin: 0 auto 6px; }
.login-card h1 { font-size: 17px; text-align: center; margin: 0 0 24px; color: var(--ink-2); font-weight: 400; }
.demo-note { background: var(--beige-50); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-top: 18px; color: var(--ink-2); }
.demo-note code { direction: ltr; unicode-bidi: isolate; background: var(--paper); padding: 0 4px; border-radius: 4px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.shell > div { min-width: 0; }
.side { background: var(--paper); border-inline-end: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .logo { width: 140px; margin: 4px 10px 22px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; }
.nav-link:hover { background: var(--sugar); color: var(--ink); }
.nav-link.active { background: var(--umber-50); color: var(--umber); font-weight: 700; }
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link .count { margin-inline-start: auto; background: var(--umber); color: #fff; font-size: 12px; min-width: 20px; padding: 0 6px; border-radius: 10px; text-align: center; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 10px 0; font-size: 13px; }
.side-foot .who { font-weight: 700; }
.mode-pill { display: inline-block; font-size: 11px; background: var(--beige-50); color: var(--umber-600); padding: 1px 8px; border-radius: 10px; margin-top: 6px; }

.main { min-width: 0; padding: 28px 32px 64px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 24px; }
.page-head .sub { color: var(--ink-3); font-size: 14px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--paper); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--umber); border-color: var(--umber); color: #fff; }
.btn.primary:hover { background: var(--umber-600); }
.btn.danger { color: var(--danger); border-color: #e4bcb6; }
.btn.danger:hover { background: var(--danger-50); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line-2); background: #fff; border-radius: 8px; padding: 8px 10px; }
.input:focus { outline: 2px solid var(--beige); outline-offset: 0; border-color: var(--beige); }
textarea.input { min-height: 80px; resize: vertical; }
input.ltr { direction: ltr; text-align: right; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-error { background: var(--danger-50); color: var(--danger); border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; font-size: 14px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input { width: auto; min-width: 140px; }
.toolbar .search { flex: 1; min-width: 200px; }
.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--line-2); border-radius: 8px; padding: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--umber-50); color: var(--umber); font-weight: 700; }

/* ---------- cards / stats ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.card-head h3 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--ink-3); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.3; }
.stat .foot { font-size: 12px; color: var(--ink-3); }
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }

.progress { height: 8px; background: var(--sugar); border-radius: 4px; overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 1px 9px; border-radius: 20px; white-space: nowrap; background: var(--sugar); color: var(--ink-2); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.available { background: var(--green); color: var(--green-ink); }
.badge.pending { background: var(--beige-50); color: #8a5a17; }
.badge.reserved, .badge.approved { background: #f4d9a8; color: #6e4a0c; }
.badge.sold { background: var(--umber-50); color: var(--umber); }
.badge.handed { background: #2b2623; color: #f7f0ec; }
.badge.unavailable, .badge.cancelled, .badge.rejected { background: #ece8e5; color: #6d6560; }
.badge.not_started { background: #ece8e5; color: #6d6560; }
.badge.scheduled { background: var(--beige-50); color: #8a5a17; }
.badge.in_progress { background: #f4d9a8; color: #6e4a0c; }
.badge.done { background: var(--green); color: var(--green-ink); }
.badge.role { background: var(--beige-50); color: var(--umber-600); }
.badge.plain::before { display: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12.5px; color: var(--ink-3); font-weight: 400; background: #fbf7f4; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #fbf6f2; }
td.wrap { white-space: normal; min-width: 180px; }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-3); }
@media (max-width: 1100px) { .hide-md { display: none; } th, td { padding: 10px 10px; } }

/* ---------- unit board ---------- */
.floor-block { margin-bottom: 18px; }
.floor-block h4 { margin: 0 0 8px; font-size: 14px; color: var(--ink-2); font-weight: 700; }
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.unit-tile { text-align: start; background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.unit-tile:hover { box-shadow: var(--shadow); }
.unit-tile .code { font-size: 20px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.unit-tile .meta { font-size: 13px; color: var(--ink-2); }
.unit-tile .price { font-weight: 700; margin-top: 4px; }
.unit-tile.available { border-top-color: #9dbb80; }
.unit-tile.pending { border-top-color: var(--beige); }
.unit-tile.reserved { border-top-color: #d9a441; }
.unit-tile.sold { border-top-color: var(--umber); }
.unit-tile.handed { border-top-color: #2b2623; }
.unit-tile.unavailable { border-top-color: #b9b1ab; opacity: .75; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; }

/* Several projects: tabs, a header that stays pinned while scrolling its units, and a tag on each tile. */
:root { --sticky-top: 0px; }
.project-tabs { margin-bottom: 14px; }
.project-tabs button { font-size: 15px; padding: 7px 14px; }
.project-head { position: sticky; top: var(--sticky-top); z-index: 5; display: flex; justify-content: space-between;
  align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 18px 0 12px; padding: 10px 14px;
  background: var(--paper); border: 1px solid var(--line); border-inline-start: 4px solid var(--umber);
  border-radius: var(--radius); box-shadow: 0 2px 8px rgba(60, 35, 20, .06); }
.project-head strong { font-size: 17px; color: var(--umber); }
.project-group:first-child .project-head { margin-top: 0; }
.tile-project { font-size: 11.5px; font-weight: 700; color: var(--umber); line-height: 1.2; }

/* Reservation countdown: calm, then amber under 5 days, red once expired. */
.countdown { display: inline-block; font-weight: 700; padding: 0 8px; border-radius: 20px; font-size: 12.5px; white-space: nowrap; }
.countdown.ok { background: var(--green); color: var(--green-ink); }
.countdown.soon { background: #f4d9a8; color: #6e4a0c; }
.countdown.expired { background: var(--danger-50); color: var(--danger); }

/* Feed entries that lead somewhere (a lead to take, a unit to open). */
.feed li.actionable { cursor: pointer; border-radius: 8px; margin-inline: -8px; padding-inline: 8px; }
.feed li.actionable:hover { background: #fbf5f0; }
.feed li.actionable:focus-visible { outline: 2px solid var(--beige); outline-offset: 0; }
.feed .feed-cta { color: var(--umber); font-weight: 700; }
.feed li.pinned.actionable { margin: 0 -12px; padding-inline: 12px; }

/* ---------- feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--sugar); font-size: 15px; }
.feed .dot.sale { background: var(--umber-50); }
.feed .dot.reservation { background: #f4d9a8; }
.feed .dot.handover { background: var(--green); }
.feed .dot.announcement { background: var(--umber); color: #fff; }
.feed .body { flex: 1; min-width: 0; white-space: pre-wrap; word-wrap: break-word; }
.feed .meta { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.feed li.pinned { background: #fbf4ee; margin: 0 -12px; padding-inline: 12px; border-radius: 8px; }
.composer textarea { min-height: 64px; }
.composer .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.approval { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.approval + .approval { margin-top: 10px; }
.approval .top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.approval .actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- drawer / modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(29, 20, 14, .35); z-index: 40; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(520px, 100vw); background: var(--paper); z-index: 41; display: flex; flex-direction: column; box-shadow: -8px 0 32px rgba(0,0,0,.12); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--paper); z-index: 41; border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 8px; }
.panel-head h3 { margin: 0; font-size: 18px; }
.panel-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
.x { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--ink-3); line-height: 1; padding: 4px 8px; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kv div { background: var(--sugar); border-radius: 8px; padding: 8px 10px; }
.kv dt { font-size: 12px; color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 700; }
.section-title { font-size: 14px; color: var(--ink-2); margin: 20px 0 8px; font-weight: 700; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.list-plain li:last-child { border-bottom: 0; }

.checklist label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.checklist label:hover { background: var(--sugar); }
.checklist input { width: 18px; height: 18px; accent-color: var(--umber); }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow); animation: fade .2s; }
.toast.error { background: var(--danger); }

/* ---------- mobile ---------- */
.mobile-bar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  :root { --sticky-top: 58px; } /* keep pinned project headers below the phone top bar */
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; min-height: 58px; }
  .mobile-bar img { width: 110px; }
  .bottom-nav { position: fixed; bottom: 0; inset-inline: 0; background: var(--paper); border-top: 1px solid var(--line); display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav .nav-link { flex: 1; flex-direction: column; gap: 0; font-size: 11px; padding: 8px 2px; border-radius: 0; position: relative; }
  .bottom-nav .nav-link .count { position: absolute; top: 3px; left: 50%; margin: 0 0 0 -24px; font-size: 10px; min-width: 16px; padding: 0 4px; }
  .main { padding: 18px 16px 90px; }
  .dash-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-head h2 { font-size: 20px; }

  /* Lists become stacked cards on phones: each cell shows its column name. */
  table.cards-sm thead { display: none; }
  table.cards-sm, table.cards-sm tbody, table.cards-sm tr { display: block; width: 100%; }
  table.cards-sm tr { border-bottom: 1px solid var(--line); padding: 10px 14px; }
  table.cards-sm tbody tr:last-child { border-bottom: 0; }
  table.cards-sm td { display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: 0; padding: 3px 0; white-space: normal; text-align: end; min-height: 26px; }
  table.cards-sm td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: 12.5px; text-align: start; flex: none; }
  table.cards-sm td:first-child { font-size: 16px; justify-content: flex-start; }
  table.cards-sm td:first-child::before { display: none; }
  table.cards-sm td.hide-md { display: none; }
  table.cards-sm td.actions { justify-content: flex-start; flex-wrap: wrap; padding-top: 8px; }
  table.cards-sm td.actions:empty { display: none; }
  .table-wrap:has(> table.cards-sm) { overflow-x: visible; }

  /* 16px fields stop iOS Safari zooming in on focus; larger tap targets. */
  .input, select.input, textarea.input { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 34px; padding: 5px 12px; }
  .toolbar .input { min-width: 0; flex: 1 1 140px; }
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .seg button { white-space: nowrap; }
  .drawer { width: 100vw; }
  .modal { width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px); }
  .panel-foot .btn { flex: 1 1 auto; }
  .unit-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (min-width: 861px) { .bottom-nav { display: none; } }

/* ---------- unit photos ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gallery-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gallery-title label.disabled { pointer-events: none; opacity: .5; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-bottom: 10px; }
.gallery-item { padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: var(--sugar); cursor: pointer; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.share-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn svg.wa { width: 18px; height: 18px; flex: none; }
.viewer { background: var(--sugar); border-radius: 8px; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 60vh; object-fit: contain; display: block; }
.viewer-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.photo-count { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 400; color: var(--ink-3); margin-inline-start: 8px; vertical-align: middle; }
.photo-count svg { width: 14px; height: 14px; }
