/* Handover stages: shared pieces (deadline badge, apartment drawer list, groups card on Struktur),
   the Təhvil mərhələləri page and the İstifadəçilər page. */

/* --- Deadline badge: the text says it, the colour backs it up --- */
.due {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--bg); color: var(--ink-2);
}
.due.soon { background: #FFF5E6; color: #8A4B00; }
.due.late { background: var(--danger-soft); color: var(--danger); }
.due.done { background: #E8F6EE; color: #1E6E40; }

/* --- Groups card above the apartment list --- */
.stage-groups { margin-bottom: 16px; }
.stage-card { padding: 18px 22px 10px; }
.stage-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.stage-card-head h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.stage-card-head h2 svg { width: 18px; height: 18px; color: var(--brand); }
.stage-card-head > span { font-size: 13px; color: var(--muted); }
.sg-list { list-style: none; margin: 0; padding: 0; }
.sg-list li {
  display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(200px, 1fr) minmax(150px, .9fr) auto;
  gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-soft);
}
.sg-list li:first-child { border-top: 0; }
.sg-name b { display: block; font-weight: 600; }
.sg-kind {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 1px 8px; border-radius: var(--r-pill);
  background: var(--bg); font-size: 12px; font-weight: 500; color: var(--ink-2); vertical-align: 2px;
}
.sg-name span, .sg-date { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.sg-name span { color: var(--muted); margin-top: 2px; }
.sg-name svg, .sg-date svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.sg-date { flex-wrap: wrap; }
.sg-progress { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.sg-progress .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.sg-progress .bar i { display: block; height: 100%; border-radius: 4px; background: var(--st-ready); }
.sg-tools, .stage-tools { display: flex; gap: 2px; }

/* Bundles: same-name batches (or one employee's, one place's) in one row that opens to them */
.sg-list li.sg-bundle { display: block; padding: 0; }
.sg-bundle-btn {
  display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(200px, 1fr) minmax(150px, .9fr) 72px; gap: 16px; align-items: center;
  width: 100%; padding: 12px 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.sg-bundle-btn:hover .sg-name b { color: var(--brand-ink); }
.sg-bundle-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 10px; }
.sg-bundle .sg-name span { display: block; overflow-wrap: anywhere; }
.sg-chev { justify-self: end; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--bg); color: var(--ink-2); transition: transform .15s; }
.sg-chev svg { width: 16px; height: 16px; transform: rotate(90deg); }
.sg-bundle.is-open .sg-chev { transform: rotate(180deg); background: var(--sky); color: var(--brand-ink); }
.sg-list li.sg-inner { display: block; padding: 0 0 10px 16px; border-top: 0; }
.sg-inner > .sg-list { border-left: 2px solid var(--line); padding-left: 14px; }
.sg-inner > .sg-list li { padding: 10px 0; }
.sg-inner .sg-name b { font-weight: 500; }
.sg-more { margin: 6px 0 10px; }
.sg-inner .sg-more { margin: 6px 0 0 16px; }
.sg-all { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 8px; padding: 10px; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--brand-ink); text-decoration: none; }
.sg-all:hover { background: var(--bg); }
.sg-all svg { width: 16px; height: 16px; }
/* «Mərhələ qrupları» page */
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.back-link svg { width: 16px; height: 16px; transform: rotate(180deg); }
.back-link:hover { color: var(--brand-ink); }
.sgp-filters .scope-extra { margin-top: 0; }
.sgp-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.sgp-row .chips { margin: 0; }
.sgp-label { flex: none; min-width: 92px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* --- Apartment drawer --- */
.section-title.section-row { justify-content: space-between; }
.section-title.section-row::after { display: none; }
.section-title.section-row .btn { text-transform: none; letter-spacing: 0; font-size: 13px; }
.stage-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stage-list li {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center;
  padding: 10px 10px 10px 12px; border: 1px solid var(--line-soft); border-radius: 16px;
}
.stage-check {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1.5px solid #CFCFCF; border-radius: 10px; background: var(--surface); color: transparent; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.stage-check svg { width: 18px; height: 18px; }
.stage-check:not(:disabled):hover { border-color: var(--st-ready); color: var(--st-ready); }
.stage-check[aria-pressed="true"] { background: var(--st-ready); border-color: var(--st-ready); color: #fff; }
.stage-check:disabled { cursor: default; opacity: .55; }
.stage-check:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.stage-text { min-width: 0; }
.stage-text b { display: block; font-weight: 600; font-size: 14.5px; }
.stage-text span { display: block; font-size: 12.5px; color: var(--muted); }
.stage-text .done-line { color: #1E6E40; }
.stage-list li.is-done .stage-text b { color: var(--ink-2); }

/* --- Shared page layout (stages, users) --- */
:is([data-page="stages"], [data-page="users"]) .page-head h1 .count { font-size: 18px; font-weight: 500; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
:is([data-page="stages"], [data-page="users"]) .list-card { overflow: hidden; }
[data-page="stages"] .pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; font-size: 14px; color: var(--ink-2); }
[data-page="stages"] .pager .nav-btns { display: flex; gap: 6px; }
[data-page="stages"] .pager .icon-btn { border: 1px solid var(--line); }
[data-page="stages"] .pager .icon-btn:disabled { opacity: .4; cursor: default; background: none; }
.chip[data-late] { color: var(--danger); }
.chip[data-late][aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.cell-label { display: none; }

/* --- Stages page: step filter --- */
.scope-card { padding: 18px 20px; margin-bottom: 4px; }
.scope-steps { display: grid; grid-template-columns: repeat(var(--steps, 5), minmax(0, 1fr)); gap: 12px; }

/* Mənzillər | Qaraj yerləri | Obyektlər - only when the stages span more than one kind */
.kind-tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 16px; border-radius: var(--r-pill);
  background: var(--bg); width: max-content; max-width: 100%; overflow-x: auto;
}
.kind-tabs[hidden] { display: none; }
.kind-tabs [role="tab"] {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border: 0; border-radius: var(--r-pill);
  background: none; font: inherit; font-size: 14.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.kind-tabs [role="tab"] svg { width: 17px; height: 17px; }
.kind-tabs [role="tab"] .n { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kind-tabs [role="tab"]:hover { color: var(--ink); background: #fff; }
.kind-tabs [role="tab"][aria-selected="true"] { background: var(--ink); color: #fff; }
.kind-tabs [role="tab"][aria-selected="true"] .n { color: rgba(255, 255, 255, .7); }
.step label { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.step-no {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--line-soft); color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.step.is-set .step-no { background: var(--brand); color: #fff; }
.step .select:disabled { opacity: .55; }
.scope-extra { display: flex; gap: 12px; margin-top: 14px; }
.scope-extra .search { flex: 1; }
.scope-extra .search > svg { width: 18px; height: 18px; }
.staff-filter { width: 280px; flex: none; }

/* --- Stages page: apartments --- */
.sa-row {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) 190px 250px 24px; gap: 16px; align-items: center;
  width: 100%; min-height: 64px; padding: 10px 22px; border: 0; border-bottom: 1px solid var(--line-soft);
  background: none; font: inherit; font-size: 14.5px; text-align: left; color: var(--ink); cursor: pointer;
  transition: background .15s var(--ease);
}
.sa-row:last-child { border-bottom: 0; }
.sa-row:hover { background: var(--bg); }
.sa-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.sa-no { font-size: 18px; font-weight: 600; }
.sa-no.is-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-no small { font-size: 12px; font-weight: 500; color: var(--muted); margin-right: 2px; }
.sa-where { min-width: 0; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-prog { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.sa-prog .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.sa-prog .bar i { display: block; height: 100%; border-radius: 4px; background: var(--st-ready); }
.sa-due { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px 8px; font-size: 13.5px; color: var(--ink-2); }
.sa-go { display: flex; color: var(--muted); }
.sa-go svg { width: 18px; height: 18px; }

/* --- Stages page: apartment drawer --- */
.stage-list.big li { grid-template-columns: 1fr auto; gap: 10px 12px; padding: 14px 14px 14px 16px; }
.stage-list.big .stage-text b { font-size: 15.5px; }
.stage-list.big .stage-text span { font-size: 13px; margin-top: 2px; }
.stage-list.big .done-line { display: flex; align-items: center; gap: 4px; }
.stage-list.big .done-line svg { width: 14px; height: 14px; flex: none; }
.stage-list.big .stage-act { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
.stage-list.big .stage-act:empty { display: none; }
.stage-list.big .stage-act .btn { flex: 1; }
.stage-list.big .stage-act .btn svg { width: 16px; height: 16px; }
[data-page="stages"] .where-line { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
[data-page="stages"] .where-line .tag { font-size: 12.5px; padding: 4px 10px; border-radius: var(--r-pill); background: var(--bg); color: var(--ink-2); }

/* --- Users table --- */
.us-table { --cols: minmax(240px, 1.5fr) minmax(200px, 1fr) 100px 150px 96px; }
.us-row .seen { font-size: 13.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.us-row .seen small { display: none; }
.us-row .seen.none { color: var(--muted); }
.us-row .seen.is-now { color: #1E6E40; font-weight: 500; }
.us-row .seen i { width: 8px; height: 8px; border-radius: 50%; background: #2E9E5B; box-shadow: 0 0 0 3px rgba(46, 158, 91, .18); flex: none; }
.us-head, .us-row { display: grid; grid-template-columns: var(--cols); gap: 16px; align-items: center; padding: 0 22px; }
.us-head {
  height: 46px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line-soft);
}
.us-row { min-height: 64px; border-bottom: 1px solid var(--line-soft); font-size: 14.5px; }
.us-row:last-child { border-bottom: 0; }
.us-row .nm { display: flex; align-items: center; gap: 12px; min-width: 0; font-weight: 600; }
.us-row .nm small { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.us-row .av {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--sky); color: var(--brand-ink); font-size: 13px; font-weight: 600;
}
.us-row.is-off .nm { color: var(--muted); }
.us-row.is-off .av { background: var(--line-soft); color: var(--muted); }
.role-chip { font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: var(--r-pill); background: var(--bg); color: var(--ink-2); }
.role-chip[data-role="HandoverStaff"] { background: var(--sky); color: var(--brand-ink); }
.role-chip[data-role="Superadmin"] { background: var(--ink); color: #fff; }
.us-row .st .on { color: #1E6E40; }
.us-row .st .off { color: var(--muted); }
.us-row .tools { display: flex; justify-content: flex-end; gap: 2px; }

@media (max-width: 1100px) {
  .scope-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sa-row { grid-template-columns: 80px minmax(0, 1fr) 160px 24px; }
  .sa-due { grid-column: 2 / 4; justify-content: flex-start; }
  .sa-go { grid-column: 4; grid-row: 1; }
}

@media (max-width: 1000px) {
  .sg-list li { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .sg-bundle-btn { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .sg-bundle-btn .sg-name { grid-column: 1; }
  .sg-bundle-btn .sg-chev { grid-column: 2; grid-row: 1; }
  .sg-bundle-btn .sg-date, .sg-bundle-btn .sg-progress { grid-column: 1 / -1; }
  .sgp-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .sg-name { grid-column: 1; }
  .sg-tools { grid-column: 2; grid-row: 1; }
  .sg-date, .sg-progress { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .stage-card { padding: 16px 16px 6px; }
  .stage-list li { grid-template-columns: auto 1fr auto; }
  .stage-list .due { grid-column: 2; justify-self: start; }
  .stage-list .stage-tools { grid-column: 3; grid-row: 1; }

  .stage-list.big li { grid-template-columns: 1fr auto; }
  .stage-list.big .due { grid-column: 2; grid-row: 1; justify-self: end; }

  .scope-card { padding: 14px; }
  .scope-steps { grid-template-columns: 1fr 1fr; gap: 10px; }
  .scope-extra { flex-direction: column; }
  .staff-filter { width: 100%; }
  .sa-row { grid-template-columns: auto minmax(0, 1fr) 20px; gap: 6px 12px; padding: 14px 16px; }
  .sa-no { grid-row: 1 / 4; align-self: start; }
  .sa-where, .sa-prog, .sa-due { grid-column: 2; justify-content: flex-start; }
  .sa-go { grid-column: 3; grid-row: 1 / 4; }
  .cell-label { display: inline; color: var(--muted); }
  .us-head { display: none; }
  .us-row { grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 16px; }
  .us-row .nm { grid-column: 1; }
  .us-row .tools { grid-column: 2; grid-row: 1; }
  .us-row > span:nth-child(2), .us-row .st, .us-row .seen { grid-column: 1 / -1; padding-left: 48px; }
  .us-row .seen { white-space: normal; flex-wrap: wrap; }
  .us-row .seen small { display: inline; font-size: 13px; color: var(--muted); }
  [data-page="users"] .page-head .actions { width: 100%; }
  [data-page="users"] .page-head .actions .btn { flex: 1; }
}

@media (max-width: 760px) {
  .kind-tabs { width: 100%; }
  .kind-tabs [role="tab"] { flex: 1; justify-content: center; gap: 6px; padding: 0 8px; font-size: 13.5px; }
}
@media (max-width: 420px) {
  .kind-tabs [role="tab"] svg { display: none; }
}

/* "Təhvil mərhələləri tətbiq olunsun?" - offered right after units are added */
.stage-offer .modal-body { max-height: min(60vh, 520px); overflow-y: auto; }
.stage-offer .stage-offer-all { display: flex; margin-left: auto; }
.stage-offer .check:first-of-type { margin-top: 8px; }
.stage-offer .check.is-off { opacity: .55; cursor: not-allowed; }

/* --- Unit facts (parking place / object drawer) --- */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.facts dd span { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.facts dd .none { display: inline; }

/* --- History: newest first, a quiet timeline --- */
.history { list-style: none; margin: 0; padding: 0; display: grid; }
.history li { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; }
.history li:not(:last-child)::before {
  content: ''; position: absolute; left: 15.5px; top: 34px; bottom: 2px; width: 1px; background: var(--line-soft);
}
.history .h-ic {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg); color: var(--ink-2);
}
.history .h-ic svg { width: 15px; height: 15px; }
.history .is-done .h-ic { background: var(--st-ready-bg, #E5F5EC); color: #1E6E40; }
.history .is-new .h-ic { background: var(--sky); color: var(--brand-ink); }
.history .is-del .h-ic { background: #FDECEC; color: var(--danger); }
.history .h-body { min-width: 0; padding-top: 5px; }
.history .h-body b { display: block; font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.history .h-details { display: grid; gap: 1px; margin-top: 3px; font-size: 13.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.history time { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }

/* --- Apartment drawer before «Redaktə et»: the same fields, read as text --- */
.drawer.is-view .input:disabled, .drawer.is-view .select:disabled, .drawer.is-view .textarea:disabled {
  background: transparent; border-color: transparent; box-shadow: none; padding-left: 0; padding-right: 0;
  color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 1; cursor: default;
  appearance: none; -webkit-appearance: none; background-image: none; height: auto; min-height: 0;
}
.drawer.is-view .textarea:disabled { resize: none; min-height: 0; }
.drawer.is-view .textarea:disabled:placeholder-shown { display: none; }
.drawer.is-view .check:has(input:disabled) { cursor: default; }
.drawer.is-view .field label { color: var(--muted); font-size: 12.5px; }
.act-text { font-weight: 600; }
.act-text small, .act-text .none { font-weight: 400; color: var(--muted); }

/* --- Stage photos (handover / edit) --- */
.sp-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin: 8px 0; }
.sp-thumbs.sm { grid-template-columns: repeat(auto-fill, 56px); gap: 6px; margin: 6px 0 0; }
.sp-thumb {
  position: relative; display: block; aspect-ratio: 1; border: 1px solid var(--line-soft);
  border-radius: 12px; overflow: hidden; background: var(--bg);
}
.sp-thumbs.sm .sp-thumb { border-radius: 10px; }
.sp-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sp-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.sp-thumb.is-broken::after { content: 'Açılmadı'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.sp-thumb.is-removed img { opacity: .3; filter: grayscale(1); }
.sp-x {
  position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(20, 20, 20, .65); color: #fff; cursor: pointer;
}
.sp-x svg { width: 14px; height: 14px; }
.sp-x[aria-pressed="true"] { background: var(--brand); }
.sp-pick-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp-pick-btns .btn { justify-content: center; }
.sp-pick-btns .btn svg { width: 18px; height: 18px; }
.sp-picker .hint { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.sp-picker .hint.is-err { color: var(--danger); }
.sp-field .sp-none { margin: 0 0 8px; }
.edit-wait {
  display: inline-flex !important; align-items: center; gap: 5px; width: fit-content; margin-top: 6px;
  padding: 3px 10px; border-radius: var(--r-pill); background: #FFF5E6; color: #8A4B00 !important; font-size: 12px !important; font-weight: 500;
}
.edit-wait svg { width: 13px; height: 13px; flex: none; }

/* --- Dashboard: edits waiting for approval --- */
[data-edits] { margin-bottom: 20px; }
[data-edits]:empty { display: none; }
.ed-card.has-items { border-color: #F5D9A8; }
.ed-count {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; margin-left: 6px;
  border-radius: var(--r-pill); background: #FFF5E6; color: #8A4B00; font-size: 14px; vertical-align: middle;
}
.ed-list { display: grid; gap: 14px; }
.ed-item { border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: grid; gap: 12px; }
.ed-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ed-head b { display: block; font-size: 15.5px; font-weight: 600; }
.ed-where { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.ed-who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.ed-who svg { width: 15px; height: 15px; color: var(--muted); }
.ed-why { display: flex; gap: 8px; margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--sky); font-size: 13.5px; color: var(--ink-2); }
.ed-why svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--brand); }
.ed-compare { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: stretch; }
.ed-arrow { display: grid; place-items: center; color: var(--muted); }
.ed-arrow svg { width: 20px; height: 20px; }
.ed-side { border-radius: 14px; background: var(--bg); padding: 12px 14px; }
.ed-side.is-after { background: #F2FAF5; }
.ed-side h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ed-side dl { margin: 0; display: grid; gap: 8px; }
.ed-row { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 8px; font-size: 13.5px; }
.ed-row dt { color: var(--muted); }
.ed-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ed-row.is-old dd { text-decoration: line-through; text-decoration-color: rgba(200, 60, 40, .6); color: var(--ink-2); }
.ed-row.is-new dd { font-weight: 600; }
.ed-row .due { display: inline-block; }
.ed-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.ed-empty { color: var(--muted); font-weight: 400; }
.ed-tag {
  position: absolute; left: 3px; bottom: 3px; padding: 1px 5px; border-radius: 6px;
  font-size: 10px; font-weight: 600; color: #fff; pointer-events: none;
}
.ed-tag.del { background: var(--danger); }
.ed-tag.new { background: var(--st-ready); }
.ed-foot { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 760px) {
  .ed-compare { grid-template-columns: 1fr; }
  .ed-arrow { transform: rotate(90deg); }
  .ed-foot .btn { flex: 1; justify-content: center; }
}
[data-page="stages"] [data-edits]:not(:empty) { margin-bottom: 20px; }

/* --- Structure page: stages on the selected element itself --- */
[data-own-stages] { margin-bottom: 16px; }
.own-card .own-empty { margin: 0; padding: 4px 0; }
.own-card .sg-list li { cursor: pointer; }
.own-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 0 8px; }
.own-foot:empty { display: none; }

/* --- Phones: nothing cut off, long places wrap, finger-sized tools --- */
.ed-card:not(.has-items) .card-head { padding-bottom: 18px; }
@media (max-width: 760px) {
  /* Status chips wrap instead of scrolling out of the screen. */
  [data-page="stages"] .chips { flex-wrap: wrap; overflow: visible; margin-left: 0; margin-right: 0; padding: 0; }
  /* A unit row: number on top, then the place (wrapping, marks visible), progress and deadline. */
  .sa-row { grid-template-columns: minmax(0, 1fr) 20px; gap: 6px 10px; }
  .sa-no { grid-row: auto; grid-column: 1; }
  .sa-no.is-name { white-space: normal; overflow-wrap: anywhere; }
  .sa-where { grid-column: 1; white-space: normal; overflow: visible; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.4; }
  .sa-prog, .sa-due { grid-column: 1; }
  .sa-go { grid-column: 2; grid-row: 1 / span 4; align-self: center; }
  .sa-due { justify-content: flex-start; }
  [data-page="stages"] .pager { padding: 12px 16px; }
  /* Groups card / drawer stage list: 40px tools. */
  .sg-tools .icon-btn, .stage-tools .icon-btn { width: 40px; height: 40px; }
  .sg-name b { overflow-wrap: anywhere; }
  .stage-check { width: 40px; height: 40px; }
  .sp-x { width: 32px; height: 32px; }
  .sp-thumbs.sm { grid-template-columns: repeat(auto-fill, 64px); }
  .ed-row { grid-template-columns: 72px minmax(0, 1fr); }
  .ed-who { white-space: normal; }
}
@media (max-width: 760px) {
  /* Project gets the full width (its names are the longest); Faza/Bina and Blok/Mərtəbə pair up below. */
  .scope-steps > .step:first-child { grid-column: 1 / -1; }
}
/* Photo picker: the two buttons share the row without spilling out of the modal */
.sp-pick-btns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sp-pick-btns .btn { min-width: 0; padding-left: 10px; padding-right: 10px; white-space: normal; height: auto; min-height: 44px; line-height: 1.2; text-align: center; }
@media (max-width: 420px) { .sp-pick-btns { grid-template-columns: minmax(0, 1fr); } }

/* --- Stage notes: a log of text and photos, added without handing the stage over --- */
.st-notes { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.st-notes-head { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.st-notes-head > div { flex: 1; min-width: 0; }
.st-notes-head h3 { overflow-wrap: anywhere; }
.st-notes-body { overflow-y: auto; display: grid; gap: 16px; padding-top: 16px; }
.st-note-form { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #FAFBFD; }
.st-note-form .field + .field { margin-top: 0; }
.st-note-form .textarea { min-height: 76px; resize: vertical; }
.st-note-submit { display: flex; justify-content: flex-end; }
/* Category of a new note: three pills, one must be picked */
.nk-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.nk-pick label { --nk: #667085; position: relative; cursor: pointer; }
.nk-pick label.nk-problem { --nk: #D92D20; }
.nk-pick label.nk-delay { --nk: #E8590C; }
.nk-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.nk-pick span { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-size: 14px; font-weight: 600; color: var(--ink-2); transition: background .12s, border-color .12s, color .12s; }
.nk-pick span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--nk); }
.nk-pick input:checked + span { background: var(--nk); border-color: var(--nk); color: #fff; }
.nk-pick input:checked + span::before { background: #fff; }
.nk-pick input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.st-note-top .nk { flex: none; margin-right: 0; }
.st-note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.st-note-list li { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.st-note-top { display: flex; align-items: center; gap: 10px; }
.st-note-top .av {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 600; color: var(--brand-ink); background: var(--sky);
}
.st-note-who { flex: 1; min-width: 0; display: grid; }
.st-note-who b { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.st-note-who time { font-size: 12px; color: var(--muted); }
.st-note-text { margin-top: 8px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.stage-list.big .stage-act .st-notes-btn { flex: 1; }
@media (max-width: 560px) {
  .st-notes { width: 100%; }
  .st-note-submit .btn { flex: 1; justify-content: center; }
}
