/* Bina xəritəsi - the building drawn as a building: sky, clouds, trees, a facade of apartment windows */
.modal.bmap {
  width: min(1320px, calc(100vw - 24px)); height: calc(100vh - 32px); max-height: none;
  display: flex; flex-direction: column; overflow: hidden; padding: 0;
}
.bm-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.bm-head h3 { margin: 0; }
.bm-head p { margin: 2px 0 0; color: var(--muted, #888); font-size: 13px; }

.bm-summary {
  display: grid; grid-template-columns: minmax(220px, 1.3fr) auto auto; align-items: center; gap: 10px 24px;
  padding: 4px 20px 14px;
}
.bm-total > span { display: block; font-size: 12.5px; color: var(--muted, #888); margin-bottom: 4px; }
.bm-kpis { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted, #888); }
.bm-kpis b { color: var(--ink, #2C2929); font-size: 15px; margin-right: 3px; }
.bm-kpis .is-late b { color: var(--st-issue, #D93B3B); }
.bm-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted, #888); justify-self: end; }
.bm-legend span { display: inline-flex; align-items: center; gap: 5px; }
.bm-legend i { width: 12px; height: 12px; border-radius: 0; border: 2px solid #F4F4F2; outline: 1px solid #C9CFD8; }
.bm-legend .lg-full { background: #2F7550; }
.bm-legend .lg-part { background: #34506F; }
.bm-legend .lg-late { background: #8A3E30; }
.bm-legend .lg-none { background: #7A848F; }

/* Progress bars */
.bm-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bm-track { flex: 1; height: 8px; border-radius: 999px; background: #E6EAF0; overflow: hidden; min-width: 30px; }
.bm-track i { display: block; height: 100%; border-radius: inherit; background: #377EF6; transition: width .5s ease; }
.bm-bar b { font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.bm-bar.is-full .bm-track i { background: #2E9E5B; }
.bm-bar.is-late .bm-track i { background: #E0711F; }
.bm-bar.is-none b { color: var(--muted, #888); }
.bm-bar.lg .bm-track { height: 12px; }
.bm-bar.lg b { font-size: 16px; min-width: 44px; }

/* --- The scene --- */
.bm-scene {
  position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain;
  background: linear-gradient(180deg, #2F7FD8 0%, #6FB2F2 40%, #CFE7FF 100%);
  border-top: 1px solid rgba(0, 0, 0, .04);
}
.bm-cloud { max-width: none !important; max-height: none !important; position: absolute; fill: #fff; opacity: .9; filter: drop-shadow(0 6px 10px rgba(60, 110, 170, .12)); pointer-events: none; }
.bm-cloud.c1 { width: 150px; top: 26px; left: 6%; animation: bm-drift 38s ease-in-out infinite alternate; }
.bm-cloud.c2 { width: 110px; top: 90px; right: 9%; opacity: .8; animation: bm-drift 46s ease-in-out infinite alternate-reverse; }
.bm-cloud.c3 { width: 90px; top: 210px; left: 18%; opacity: .7; animation: bm-drift 52s ease-in-out infinite alternate; }
.bm-cloud.c4 { width: 170px; top: 40px; right: 30%; opacity: .75; animation: bm-drift 60s ease-in-out infinite alternate-reverse; }
@keyframes bm-drift { from { transform: translateX(-30px); } to { transform: translateX(40px); } }

.bm-stage {
  position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: center; gap: 8px;
  width: max-content; min-width: 100%; padding: 70px 12px 0; margin: 0 auto;
}
.bm-ground {
  position: sticky; left: 0; height: 46px; margin-top: -14px; width: 100%; min-width: max-content;
  background: linear-gradient(180deg, #7CC96B 0 14px, #66B556 14px 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .25);
}
.bm-trees { display: flex; align-items: flex-end; gap: 4px; margin-bottom: -2px; }
.bm-tree { height: var(--h) !important; width: auto !important; max-height: none !important; max-width: none !important; }
.bm-bush { width: var(--w) !important; height: auto !important; max-height: none !important; max-width: none !important; }
.bm-tree, .bm-bush { display: block; flex: none; filter: drop-shadow(0 4px 4px rgba(20, 70, 30, .15)); }
.bm-nothing { padding: 120px 0; color: #3B5677; }

.bm-buildings { display: flex; align-items: flex-end; gap: 22px; }

/* --- The building: light facade, terracotta piers between window pairs, white slabs, dark glass --- */
.bb { --bw: 64px; --pier: 9px; --m: 4px; --s: 8px; --terra: #C4633F; --terra-d: #A9512F; display: flex; flex-direction: column; align-items: stretch; }
.bb-roof {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -6px; padding: 9px 16px; color: #fff; font-size: 13px; font-weight: 600;
  background: linear-gradient(180deg, #D9DCDF 0 5px, #3E4652 5px 100%);
  border-bottom: 4px solid var(--terra);
}
.bb-roof b { font-size: 13px; background: rgba(255, 255, 255, .16); padding: 1px 8px; }
.bb-facade {
  padding: 0 0 0; border-left: var(--pier) solid var(--terra); border-right: var(--pier) solid var(--terra-d);
  background: #ECEBE8;
  box-shadow: 0 40px 70px -30px rgba(20, 40, 80, .55);
}
.bb-base {
  height: 34px; background: linear-gradient(180deg, #8E949C, #757B84); border-left: var(--pier) solid var(--terra);
  border-right: var(--pier) solid var(--terra-d); display: flex; justify-content: center; align-items: flex-end; gap: 10px;
}
.bb-door { width: 56px; height: 28px; background: linear-gradient(180deg, #3A4C63, #2A3849); border: 3px solid #E9E9E6; border-bottom: 0; }

.bf { display: grid; grid-template-columns: 30px auto 40px; align-items: stretch; gap: 0; }
.bf-no, .bf-pct { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #6B6E73; background: #E2E0DC; font-variant-numeric: tabular-nums; }
.bf-pct { font-size: 10.5px; }
.bf-body { display: grid; }
.bf-row { display: flex; padding: 8px 0 7px; }
.bf-empty { height: var(--bw); }
/* The white slab under a floor - it fills with the floor's progress */
.bf-slab { height: 7px; background: #FBFBF9; box-shadow: 0 1px 0 #D6D3CD, 0 -1px 0 #fff; overflow: hidden; }
.bf-slab i { display: block; height: 100%; background: #4E8FE8; }
.bf-slab.is-full i { background: #2E9E5B; }
.bf-slab.is-late i { background: #E0711F; }

/* A window = an apartment. Pairs of windows sit between terracotta piers. */
.bw {
  position: relative; width: var(--bw); height: var(--bw); flex: none; margin: 0 var(--m); padding: 6px 6px 5px;
  display: grid; grid-template-rows: 1fr auto auto; justify-items: center; gap: 3px;
  border-radius: 0; border: 3px solid #F4F4F2; cursor: pointer; font: inherit; color: #fff;
  background: linear-gradient(165deg, #5C7C9E 0%, #34506F 45%, #253A52 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25);
  transition: transform .16s cubic-bezier(.2, .8, .3, 1.3), box-shadow .16s;
}
.bw:nth-child(odd):not(:first-child) { margin-left: calc(var(--m) + var(--pier) + var(--s)); }
.bw:nth-child(odd):not(:first-child)::after { /* the pier between pairs */
  content: ''; position: absolute; top: -11px; bottom: -10px; left: calc(-1 * (var(--m) + var(--s) / 2 + var(--pier)) - 3px); width: var(--pier);
  background: linear-gradient(90deg, var(--terra), var(--terra-d)); pointer-events: none;
}
.bw:first-child { margin-left: 10px; }
.bw:last-child { margin-right: 10px; }
.bw::before { /* sky reflection on the glass */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(130deg, rgba(255, 255, 255, .28) 0 22%, rgba(255, 255, 255, 0) 22% 100%);
}
.bw-no { align-self: center; font-size: 15px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.bw-bar { width: 100%; height: 4px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.bw-bar i { display: block; height: 100%; background: #9CC8FF; }
.bw-pct { font-size: 10px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; opacity: .9; }
.bw.is-full { background: linear-gradient(165deg, #5FA27D 0%, #2F7550 50%, #1F5839 100%); }
.bw.is-full .bw-bar i { background: #9BF0BD; }
.bw.is-late { background: linear-gradient(165deg, #B5705F 0%, #8A3E30 50%, #6A2B21 100%); }
.bw.is-late .bw-bar i { background: #FFC08F; }
.bw.is-none { background: linear-gradient(165deg, #9AA3AE 0%, #7A848F 50%, #66707B 100%); }
.bw:hover, .bw:focus-visible {
  transform: scale(1.38); z-index: 5; outline: none;
  box-shadow: 0 16px 30px -10px rgba(10, 25, 50, .6), inset 0 0 0 1px rgba(0, 0, 0, .25);
}
.bw:hover::after, .bw:focus-visible::after { display: none; }
.bw:focus-visible { border-color: #FFD27A; }

/* --- Apartment modal --- */
.modal.bm-amodal { width: min(460px, calc(100vw - 24px)); padding: 0; display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.bm-d-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line-soft, #F1F1F1); }
.bm-d-head > div { flex: 1; min-width: 0; }
.bm-d-head h4 { margin: 0; font-size: 18px; }
.bm-d-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted, #888); }
.bm-d-badge {
  display: grid; place-items: center; min-width: 44px; height: 44px; padding: 0 6px; border-radius: 0; font-weight: 700; font-size: 15px;
  border: 3px solid #F4F4F2; outline: 1px solid #D6D3CD; background: linear-gradient(165deg, #5C7C9E, #253A52); color: #fff;
}
.bm-d-badge.is-full { background: linear-gradient(165deg, #5FA27D, #1F5839); }
.bm-d-badge.is-late { background: linear-gradient(165deg, #B5705F, #6A2B21); }
.bm-d-badge.is-none { background: linear-gradient(165deg, #9AA3AE, #66707B); }
.bm-d-body { overflow: auto; padding: 14px 18px 18px; display: grid; gap: 12px; }
.bm-facts { margin: 0; display: grid; gap: 5px; }
.bm-facts div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; font-size: 13.5px; }
.bm-facts dt { color: var(--muted, #888); }
.bm-facts dd { margin: 0; overflow-wrap: anywhere; }
.bm-d-body > .dm-row { margin-top: 0; }
.bm-d-progress > span { display: block; font-size: 12.5px; color: var(--muted, #888); margin-bottom: 4px; }
.bm-stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bm-stages li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line-soft, #EEF0F3); }
.bm-dot { width: 10px; height: 10px; border-radius: 50%; background: #C9D3E3; }
.bm-stages li.is-done .bm-dot { background: #2E9E5B; }
.bm-stages li.is-late .bm-dot { background: #D93B3B; }
.bm-st-main { display: grid; min-width: 0; }
.bm-st-main b { font-size: 13.5px; font-weight: 600; }
.bm-st-main small, .bm-st-state small { color: var(--muted, #888); font-size: 11.5px; }
.bm-st-state { display: grid; text-align: right; font-size: 12.5px; font-weight: 600; }
.bm-stages li.is-done .bm-st-state { color: #1E6E40; }
.bm-stages li.is-late .bm-st-state { color: #C0392B; }
.bm-d-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bm-stages li[data-stages-open] { cursor: pointer; transition: background .12s, border-color .12s; }
.bm-stages li[data-stages-open]:hover { background: #F5F8FE; border-color: #D6E3FA; }
.bm-stages li[data-stages-open]:focus-visible { outline: 2px solid var(--brand, #377EF6); outline-offset: 1px; }
.bm-muted { color: var(--muted, #888); font-size: 13px; margin: 0; }

@media (max-width: 900px) {
  .bm-summary { grid-template-columns: 1fr; }
  .bm-legend { justify-self: start; }
}
@media (max-width: 560px) {
  .modal.bmap { width: 100vw; height: 100dvh; border-radius: 0; }
  .bm-head { padding: 14px 16px 8px; }
  .bm-summary { padding: 4px 16px 12px; gap: 8px; }
  .bm-trees { display: none; }
  .bm-stage { padding: 48px 6px 0; gap: 6px; }
  .bb { --bw: 33px; --pier: 4px; --m: 2px; --s: 3px; }
  .bf { grid-template-columns: 16px auto; }
  .bf-pct { display: none; }
  .bf-no { font-size: 9.5px; }
  .bf-row { padding: 5px 0 4px; }
  .bw:first-child { margin-left: 5px; }
  .bw:last-child { margin-right: 5px; }
  .bw::after { top: -7px !important; bottom: -6px !important; }
  .bf-slab { height: 4px; }
  .bb-roof { margin: 0 -3px; font-size: 12px; padding: 6px 10px; }
  .bw { padding: 3px 2px 2px; gap: 1px; border-width: 2px; }
  .bw-no { font-size: 11px; }
  .bw-pct { font-size: 8px; }
  .bw-bar { height: 3px; }
  .bw:hover, .bw:focus-visible { transform: scale(1.5); }
  .modal.bm-amodal { top: auto; bottom: 0; left: 0; transform: none; width: 100vw; border-radius: 20px 20px 0 0; max-height: 85vh; animation: bm-up .2s ease-out; }
  .bm-d-body { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  @keyframes bm-up { from { transform: translateY(100%); } }
}
@media (prefers-reduced-motion: reduce) {
  .bm-cloud { animation: none; }
  .bw { transition: none; }
}
.bm-trees .bm-bush { display: none; }

/* Phones: taller windows (a 40px finger target even when 8 fit across), room for the home indicator */
@media (max-width: 560px) {
  .bw { height: 40px; }
  .bm-ground { height: calc(46px + env(safe-area-inset-bottom)); }
  .bm-head h3 { font-size: 18px; overflow-wrap: anywhere; }
  .bm-head > div { min-width: 0; }
  .bm-d-head h4 { overflow-wrap: anywhere; }
  .bm-d-actions .btn { flex: 1 1 auto; }
  .bm-facts div { grid-template-columns: 88px minmax(0, 1fr); }
  .bm-stages li { grid-template-columns: 10px minmax(0, 1fr) auto; }
  .bm-st-main b { overflow-wrap: anywhere; }
}
@media (max-width: 560px) {
  /* 8 windows a floor must fit a 360px screen without a sideways wiggle */
  .bm-stage { padding-left: 2px; padding-right: 2px; }
  .bf { grid-template-columns: 15px auto; }
  .bw:first-child { margin-left: 4px; }
  .bw:last-child { margin-right: 4px; }
}

/* Zoom: the drawing (trees and buildings) is scaled; sky, clouds and ground stay as they are */
.bm-stage > .bm-trees, .bm-stage > .bm-buildings { zoom: var(--z, 1); }
.modal.bmap:focus { outline: none; }
.bm-head-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.bm-zoom {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--line, #EAEAEA); border-radius: var(--r-pill, 999px); background: #fff;
}
.bm-zoom .icon-btn { width: 32px; height: 32px; border-radius: 50%; }
.bm-zoom .icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.bm-zoom-val {
  min-width: 52px; height: 32px; border: 0; background: none; border-radius: 8px; cursor: pointer;
  font: 600 13px var(--font); font-variant-numeric: tabular-nums; color: var(--ink, #2C2929);
}
.bm-zoom-val:hover { background: var(--sky, #EEF5FF); }
.bm-zoom .btn { margin-left: 4px; height: 32px; border-radius: var(--r-pill, 999px); }
.bm-zoom .btn svg { width: 14px; height: 14px; }
@media (max-width: 560px) {
  .bm-zoom .btn { display: none; }
  .bm-zoom-val { min-width: 44px; }
  .bm-head-tools { gap: 4px; }
}
