/* Zarzadca — powloka: scena (niebo, budynek, ziemia), chrome urzadzenia, warstwy (arkusze, toasty, push).
   Na komputerze: zarzadczyni po lewej, opis i elewacja Lipowej 12 w srodku, mieszkanka po prawej;
   telefony i budynek stoja na tej samej linii ziemi. W telefonie dolny pas (dok + zakladki) jest
   twarda, nieprzezroczysta strefa dotyku na betonie. */

html, body { height: 100%; }
body { background: var(--stage-bg); overflow: hidden; }
.stage { position: relative; height: 100%; }

/* ---------- urzadzenie ---------- */
.app {
  --sb-h: 0px;
  --db-h: 0px;
  --ab-h: 56px;
  --tb-h: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --view-top: calc(var(--sb-h) + var(--safe-t) + var(--db-h) + var(--ab-h));
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--bg); color: var(--ink);
  container-type: inline-size;
}
.app.is-framed { --sb-h: 44px; --safe-t: 0px; --safe-b: 16px; width: 390px; height: 844px; border-radius: 44px; }
.app.has-demobar { --db-h: 44px; }
.in-artifact .app { --safe-t: 0px; }
.in-artifact .app:not(.is-framed) { --safe-b: 0px; }

.statusbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--sb-h); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; padding: 4px 28px 0 34px;
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); pointer-events: none;
}
.app:not(.is-framed) .statusbar { display: none; }
.sb-icons { display: flex; align-items: center; gap: 6px; }

/* pasek demo (telefon) */
.demobar {
  position: absolute; left: 0; right: 0; top: calc(var(--sb-h) + var(--safe-t)); height: var(--db-h); z-index: 14;
  display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px;
  background: var(--beton); box-shadow: inset 0 calc(-1 * var(--kreska)) 0 var(--linia);
}
.app:not(.has-demobar) .demobar { display: none; }
.demo-tag {
  flex: none; padding: 3px 6px; border-radius: 3px; box-shadow: inset 0 0 0 var(--kreska) var(--mgla-2);
  font-size: 11px; font-weight: 700; font-stretch: var(--waski); letter-spacing: 0.08em; color: var(--mgla);
}
.demobar .seg { flex: 1 1 auto; }
.demobar .seg > button { min-height: 32px; font-size: 13px; }
.demobar-help {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  box-shadow: inset 0 0 0 var(--kreska) var(--mgla-2); font-weight: 700; color: var(--ink);
}

/* pasek tytulu */
.appbar {
  position: absolute; left: 0; right: 0; top: calc(var(--sb-h) + var(--safe-t) + var(--db-h)); height: var(--ab-h); z-index: 12;
  display: flex; align-items: center; gap: 2px; padding: 0 6px 0 20px;
  background: var(--bg); transition: box-shadow var(--t-krotki) var(--krzywa);
}
.app:not(.is-framed):not(.has-demobar) .appbar { box-shadow: 0 calc(-1 * var(--safe-t)) 0 var(--bg); }
.appbar.is-scrolled { box-shadow: 0 var(--kreska) 0 var(--linia); }
.appbar.has-back { padding-left: 6px; }
.ab-titles { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.ab-title { font-size: var(--t-l); font-weight: 600; letter-spacing: -0.005em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar.has-back .ab-title { font-size: var(--t-m); }
.ab-sub { font-size: 12px; font-weight: 600; font-stretch: var(--waski); letter-spacing: 0.02em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-actions { display: flex; align-items: center; flex: none; }
.ab-avatar { width: var(--tap); height: var(--tap); display: grid; place-items: center; }
.ab-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; text-align: left; min-height: var(--tap); }
.ab-brand-name { font-size: var(--t-l); font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-brand-sub { font-size: 12px; font-weight: 600; font-stretch: var(--waski); letter-spacing: 0.02em; color: var(--muted); display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.ab-brand .icon-chev { color: var(--muted); }
.znak { flex: none; width: 22px; height: 22px; }

.view {
  position: absolute; left: 0; right: 0; bottom: 0; top: var(--view-top);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.view::-webkit-scrollbar { display: none; }
.screen {
  display: flex; flex-direction: column; gap: 22px;
  padding: 6px 20px calc(var(--tb-h) + var(--safe-b) + 28px);
  min-height: 100%;
}
.app.has-dock .screen { padding-bottom: calc(var(--tb-h) + var(--safe-b) + var(--dock-h, 76px) + 24px); }
.screen-tight { gap: 14px; }

/* ---------- dolny pas: dok + zakladki na betonie ---------- */
.dock {
  position: absolute; left: 0; right: 0; bottom: calc(var(--tb-h) + var(--safe-b)); z-index: 11;
  padding: 12px 20px; background: var(--beton); box-shadow: inset 0 var(--kreska) 0 var(--linia);
}
.dock-row { display: flex; align-items: flex-end; gap: 8px; }
.dock .input { min-height: 44px; }
.dock-send { width: 44px; height: 44px; border-radius: var(--r-przycisk); display: grid; place-items: center; background: var(--kartka); color: var(--noc); flex: none; }
.dock-send:disabled { opacity: .45; }

.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 12;
  height: calc(var(--tb-h) + var(--safe-b)); padding: 0 0 var(--safe-b);
  display: flex; align-items: stretch;
  background: var(--beton); box-shadow: inset 0 var(--kreska) 0 var(--linia);
}
/* linia awarii: dopoki trwa awaria w budynku, krawedz pasa jest w kolorze sygnalu */
.app.trwa-awaria .tabbar { box-shadow: inset 0 2px 0 var(--sygnal); }
.app.trwa-awaria.has-dock .tabbar { box-shadow: inset 0 var(--kreska) 0 var(--linia); }
.app.trwa-awaria.has-dock .dock { box-shadow: inset 0 2px 0 var(--sygnal); }
.tab {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 4px; position: relative;
  font-size: var(--t-xs); font-weight: 600; font-stretch: var(--waski); letter-spacing: 0.02em; color: var(--mgla);
  -webkit-tap-highlight-color: transparent;
}
.tab[aria-current="page"] { color: var(--kartka); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 2px; background: var(--kartka); }
.tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-count { position: absolute; top: 7px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--swiatlo); color: var(--noc); font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; font-stretch: 100%; }
.tab-dot { position: absolute; top: 12px; right: 12px; width: 6px; height: 6px; border-radius: 50%; background: var(--swiatlo); }

/* ---------- warstwy ---------- */
.layer { position: absolute; inset: 0; z-index: 40; pointer-events: none; }
.pushes { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; flex-direction: column; }
.push {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 11px; width: 100%;
  padding: calc(var(--sb-h) + var(--safe-t) + 8px) 20px 16px;
  background: var(--beton); color: var(--ink); text-align: left; box-shadow: inset 0 calc(-1 * var(--kreska)) 0 var(--linia);
  animation: zjazd var(--t-sredni) var(--krzywa);
}
.push.is-urgent { background: var(--sygnal); color: oklch(1 0 0); box-shadow: none; }
.push.is-out { transform: translateY(-100%); transition: transform var(--t-sredni) var(--krzywa); }
@keyframes zjazd { from { transform: translateY(-100%); } to { transform: none; } }
.push-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.push-app { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; font-stretch: var(--waski); letter-spacing: 0.04em; opacity: .85; }
.push-title { font-size: var(--t-l); font-weight: 600; line-height: 1.2; text-wrap: balance; }
.push-text { font-size: var(--t-s); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.push-more { font-size: 12px; opacity: .85; }
.push :focus-visible { outline-color: currentColor; }

.sheets { position: absolute; inset: 0; z-index: 2; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--t-sredni) var(--krzywa); pointer-events: auto; }
.scrim.is-open { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; pointer-events: auto;
  max-height: calc(100% - var(--sb-h) - var(--safe-t) - 20px);
  display: flex; flex-direction: column;
  background: var(--noc); color: var(--ink); box-shadow: 0 calc(-1 * var(--kreska)) 0 var(--mgla-2);
  transform: translateY(105%); transition: transform var(--t-sredni) var(--krzywa);
}
.sheet.is-open { transform: none; }
.sheet-grab { flex: none; width: 36px; height: 4px; border-radius: 2px; background: var(--linia); margin: 8px auto 0; }
.sheet-head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 2px 6px 0 20px; }
.sheet-title { flex: 1 1 auto; min-width: 0; font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.01em; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.sheet-foot { flex: none; display: flex; gap: 8px; padding: 12px 20px calc(12px + var(--safe-b)); background: var(--beton); box-shadow: inset 0 var(--kreska) 0 var(--linia); }
.sheet-foot .btn { flex: 1 1 0; }

.toasts {
  position: absolute; left: 16px; right: 16px; z-index: 4;
  bottom: calc(var(--tb-h) + var(--safe-b) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.app.has-dock .toasts { bottom: calc(var(--tb-h) + var(--safe-b) + var(--dock-h, 76px) + 10px); }
.app.has-sheet .toasts { top: calc(var(--sb-h) + var(--safe-t) + 10px); bottom: auto; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%;
  padding: 11px 14px; border-radius: var(--r-przycisk); background: var(--toast-bg); color: var(--toast-ink);
  font-size: 14px; font-weight: 500; line-height: 1.35;
  animation: fade-in var(--t-sredni) var(--krzywa);
}
.toast .icon { flex: none; }
.toast.t-danger { background: var(--sygnal); color: oklch(1 0 0); }
.toast.is-out { opacity: 0; transition: opacity var(--t-sredni) var(--krzywa); }

/* ---------- powitanie (telefon): niebo, osiedle na linii ziemi, wybor roli na ziemi ---------- */
.welcome {
  position: absolute; inset: 0; z-index: 60; pointer-events: auto; overflow-y: auto;
  background: var(--noc); display: flex; flex-direction: column;
}
.welcome:focus { outline: none; }
.welcome.is-out { opacity: 0; transition: opacity var(--t-sredni) var(--krzywa); }
.welcome-niebo { background: var(--niebo); padding: calc(var(--safe-t) + 20px) 20px 0; display: flex; flex-direction: column; gap: 18px; }
.marka { display: flex; align-items: center; gap: 10px; }
.marka-nazwa { font-size: var(--t-l); font-weight: 600; }
.marka-dop { font-size: var(--t-xs); color: var(--niebo-tekst); }
.welcome-title { font-size: 30px; line-height: 1.12; font-weight: 600; letter-spacing: -0.015em; }
.welcome-osiedle { display: flex; align-items: flex-end; gap: 10px; margin: 6px -20px 0; padding: 0 12px; }
.welcome-osiedle .elewacja { flex: 1 1 0; min-width: 0; height: auto; }
.welcome-ziemia { padding: 18px 20px calc(var(--safe-b) + 20px); display: flex; flex-direction: column; gap: 14px; }
.welcome-text { font-size: var(--t-s); color: var(--ink-2); }
.welcome-roles { display: flex; flex-direction: column; gap: 10px; }
.rola {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 64px; padding: 12px 16px;
  border-radius: var(--r-przycisk); box-shadow: inset 0 0 0 var(--kreska) var(--mgla-2); text-align: left;
}
.rola b { font-size: var(--t-l); font-weight: 600; }
.rola span { font-size: var(--t-xs); color: var(--mgla); }
.rola.is-glowna { background: var(--kartka); color: var(--noc); box-shadow: none; }
.rola.is-glowna span { color: oklch(0.38 0.02 235); }
.welcome .credit { margin-top: 8px; }

/* ---------- scena na komputerze: niebo, linia ziemi ---------- */
.stage.is-framed {
  display: grid; grid-template-columns: auto minmax(360px, 520px) auto; grid-template-rows: 1fr auto;
  justify-content: center; column-gap: clamp(24px, 3vw, 56px);
  padding: 16px clamp(20px, 2.6vw, 48px) 0; overflow: auto;
  background: var(--niebo);
}
.stage.is-framed.is-single { grid-template-columns: minmax(360px, 560px) auto; }
.phones { display: contents; }
.phone { margin: 0; display: flex; flex-direction: column; gap: 8px; zoom: var(--z, 1); align-self: end; grid-row: 1; }
.phone[data-role="manager"] { grid-column: 1; }
.phone[data-role="resident"] { grid-column: 3; }
.is-single .phone { grid-column: 2; }
.frame { padding: 11px; border-radius: 55px; background: var(--bezel); box-shadow: inset 0 0 0 1px oklch(0.3 0.015 235); }
.phone-cap { height: 30px; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--niebo-tekst); white-space: nowrap; }
.rola-znak { flex: none; padding: 3px 6px; border-radius: 3px; box-shadow: inset 0 0 0 var(--kreska) var(--niebo-tekst); font-size: 11px; font-weight: 700; font-stretch: var(--waski); letter-spacing: 0.08em; color: var(--kartka); }
.cap-link { padding: 4px 0; font-size: 14px; color: var(--kartka); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.panel { grid-column: 2; grid-row: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; padding-top: 10px; }
.is-single .panel { grid-column: 1; }
.panel-marka { display: flex; align-items: center; gap: 10px; }
.panel-marka .znak { width: 26px; height: 26px; }
.panel-nazwa { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.panel-dop { font-size: var(--t-s); color: var(--niebo-tekst); }
.panel-teza { font-size: clamp(28px, 2.3vw, 36px); line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.panel-lead { font-size: var(--t-m); line-height: 1.5; color: var(--niebo-tekst); max-width: 36em; }
.panel-lead b { color: var(--kartka); font-weight: 600; }

.krok { width: 100%; display: grid; grid-template-columns: 26px 1fr; gap: 0 12px; align-items: start; padding: 4px 0; min-height: 32px; text-align: left; }
.krok-nr { width: 22px; height: 22px; border-radius: 3px; display: grid; place-items: center; margin-top: 1px; font-size: 12px; font-weight: 700; box-shadow: inset 0 0 0 var(--kreska) var(--niebo-tekst); color: var(--kartka); font-variant-numeric: tabular-nums; }
.krok-tekst { font-size: var(--t-s); line-height: 1.3; font-weight: 600; color: var(--kartka); }
.krok-tekst small { font-size: 13px; font-weight: 400; color: var(--niebo-tekst); }
.kroki li.is-done .krok-nr { background: var(--swiatlo); color: var(--noc); box-shadow: none; }
.kroki li.is-done .krok-tekst { color: var(--niebo-tekst); font-weight: 400; text-decoration: line-through; text-decoration-thickness: 1px; }
.kroki li.is-next .krok-nr { background: var(--kartka); color: var(--noc); box-shadow: none; }
.przewodnik-koniec { margin-top: 6px; font-weight: 600; }
.panel-akcje { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.qr-row { display: flex; align-items: center; gap: 10px; font-size: var(--t-xs); color: var(--niebo-tekst); }
.qr-box { width: 60px; height: 60px; padding: 4px; background: oklch(1 0 0); color: oklch(0.2 0.016 235); display: grid; place-items: center; border-radius: 3px; }
.qr-box svg, .qr-box img { width: 100%; height: 100%; }
.panel-elewacja { margin-top: auto; }
.panel-elewacja .elewacja { width: 100%; height: auto; }

/* ziemia: pas pod telefonami i budynkiem; linia na gorze czerwienieje, dopoki trwa awaria */
.ziemia {
  grid-column: 1 / -1; grid-row: 2; margin: 0 calc(-1 * clamp(20px, 2.6vw, 48px)); padding: 14px clamp(20px, 2.6vw, 48px) 16px;
  background: var(--noc); box-shadow: inset 0 2px 0 var(--beton);
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; font-size: 13px; color: var(--mgla);
}
.ziemia-stan { flex: 1 1 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage.trwa-awaria .ziemia { box-shadow: inset 0 2px 0 var(--sygnal); }
.ziemia-stan b { color: var(--kartka); font-weight: 600; font-variant-numeric: tabular-nums; }
.ziemia-linki { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.p-link { padding: 4px 0; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; color: var(--kartka); }
.p-link[aria-pressed="true"] { text-decoration: none; font-weight: 600; }
.p-confirm { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.credit { font-size: var(--t-xs); color: var(--muted); }
.credit a { color: var(--kartka); font-weight: 600; }

/* okno modalne (formularz kontaktu) */
.modal-layer {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: var(--scrim); animation: fade-in var(--t-sredni) var(--krzywa);
}
.modal {
  width: min(500px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto; border-radius: 6px;
  background: var(--noc); color: var(--ink); box-shadow: 0 0 0 var(--kreska) var(--mgla-2);
  display: flex; flex-direction: column;
}
.modal .sheet-body { overflow: visible; }

@media (max-width: 899px) {
  body { overflow: hidden; background: var(--bg); }
  .stage { height: 100dvh; }
  .in-artifact .stage { height: 100%; }
  .stage > .app { width: 100%; height: 100%; }
}
@media (hover: hover) and (pointer: fine) {
  .krok:hover .krok-tekst { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
  .p-link:hover, .cap-link:hover { text-decoration-thickness: 2px; }
}
