/* PropertyOS apps: solid content layer + glass navigation bars. */

.app {
  position: absolute; inset: 0; z-index: 10; background: var(--bg); color: var(--ink);
  display: flex; flex-direction: column; overflow: hidden; will-change: transform, opacity;
}
.app.open { transform: none; }
.app-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3; padding: calc(var(--safe-t) + 8px) 12px 8px;
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; min-height: calc(var(--safe-t) + 60px);
  background: var(--head-bg-solid);
}
html[data-glass="1"] .app-head, html[data-glass="2"] .app-head { background: var(--head-bg); backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6); }
.app-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--line); }
.app-title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-title small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-3); margin-top: -2px; }
.round { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line), 0 2px 8px rgba(13,26,45,.06); }
.round.accent { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent); }
.head-actions { display: flex; gap: 8px; justify-content: flex-end; min-width: 44px; }
.app-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: calc(var(--safe-t) + 72px) 16px calc(32px + var(--safe-b)); overscroll-behavior: contain; scrollbar-width: none; }
.app-body::-webkit-scrollbar { display: none; }
.app-body.flush { padding-left: 0; padding-right: 0; }
.stack { display: grid; gap: 14px; }
.stack.tight { gap: 8px; }
.row-flex { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.spacer { height: 12px; }
.center { text-align: center; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); letter-spacing: .06em; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- cards & lists ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: inset 0 0 0 1px var(--line); }
.card h3 { font-size: 15px; font-weight: 650; }
.sec { font-size: 13px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; padding: 6px 4px 0; display: flex; justify-content: space-between; align-items: center; }
.list { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 13px 14px; width: 100%; text-align: left; position: relative; min-height: 60px; transition: background 160ms; }
.item + .item::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line); }
button.item:active { background: var(--surface-2); }
.item .t { font-weight: 600; font-size: 15.5px; }
.item .s { font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.item .trail { text-align: right; font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; justify-items: end; }
.item .amt { font-weight: 700; font-size: 15.5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.avatar { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; font-size: 15px; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); flex: none; }
.avatar.sq { border-radius: 12px; }
.avatar.good { color: var(--good); background: var(--good-bg); }
.avatar.warn { color: var(--warn); background: var(--warn-bg); }
.avatar.bad { color: var(--bad); background: var(--bad-bg); }
.avatar.info { color: var(--info); background: var(--info-bg); }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 650; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

/* ---------- buttons ---------- */
.btn { height: 50px; padding: 0 22px; border-radius: 25px; font-weight: 650; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--surface-3); color: var(--ink); white-space: nowrap; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.good { background: var(--good); color: #fff; }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.block { width: 100%; }
.btn.sm { height: 38px; padding: 0 16px; font-size: 14px; border-radius: 19px; }
.btn.xs { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 16px; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.btn.busy::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2.4px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.fab { position: absolute; right: 18px; bottom: calc(22px + var(--safe-b)); width: 58px; height: 58px; border-radius: 50%; z-index: 4; display: grid; place-items: center; background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 12px 26px color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > label, .lbl { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 16px; border: 0; outline: 0;
  background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); font-size: 16px;
  transition: box-shadow 180ms, background 180ms;
}
.input:focus, .select:focus, .textarea:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface); }
.textarea { min-height: 92px; resize: none; line-height: 1.4; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input.big { font-size: 28px; font-weight: 650; text-align: center; min-height: 64px; letter-spacing: -.01em; }
.hint { font-size: 12.5px; color: var(--ink-3); }
.err { font-size: 13px; color: var(--bad); font-weight: 550; min-height: 0; }
.field.bad .input { box-shadow: inset 0 0 0 2px var(--bad); }
.pw { position: relative; }
.pw .input { padding-right: 52px; }
.pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink-3); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; padding: 4px; gap: 2px; border-radius: 16px; background: var(--surface-3); position: relative; }
.seg button { flex: 1; height: 38px; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); position: relative; z-index: 1; transition: color 200ms; white-space: nowrap; }
.seg button.on { color: var(--ink); background: var(--surface); box-shadow: 0 2px 8px rgba(13,26,45,.12); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { height: 40px; padding: 0 14px; border-radius: 20px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: 14px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; transition: background 160ms, color 160ms; }
.opt.on { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.check { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; font-size: 14px; color: var(--ink-2); text-align: left; }
.check i { width: 24px; height: 24px; border-radius: 8px; box-shadow: inset 0 0 0 2px var(--ink-3); display: grid; place-items: center; color: transparent; transition: background 160ms; }
.check.on i { background: var(--accent); color: #fff; box-shadow: none; }
.switch { width: 52px; height: 32px; border-radius: 16px; background: var(--surface-3); position: relative; flex: none; transition: background 220ms; box-shadow: inset 0 0 0 1px var(--line); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform var(--spring-t) var(--spring); }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(20px); }

/* ---------- sheets ---------- */
.sheet-wrap { position: absolute; inset: 0; z-index: 30; display: flex; align-items: flex-end; }
.sheet-wrap .scrim { position: absolute; inset: 0; }
.sheet {
  position: relative; width: 100%; max-height: 92%; background: var(--bg); color: var(--ink); border-radius: 30px 30px 0 0;
  display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(0,0,0,.25); animation: sheet-in var(--spring-t) var(--spring) both; will-change: transform;
}
.sheet.out { animation: sheet-out 240ms cubic-bezier(.4,0,1,1) forwards; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
.sheet.dragging { animation: none; transition: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--ink-3); opacity: .45; margin: 9px auto 0; flex: none; touch-action: none; }
.sheet-head { padding: 8px 20px 6px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex: none; touch-action: none; }
.sheet-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.sheet-body { overflow-y: auto; padding: 8px 18px calc(24px + var(--safe-b)); overscroll-behavior: contain; scrollbar-width: none; display: grid; gap: 14px; align-content: start; }
.sheet-body::-webkit-scrollbar { display: none; }
.x { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; color: var(--ink-2); flex: none; }

/* ---------- numbers & stats ---------- */
.hero-num { font-size: 44px; font-weight: 300; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hero-num small { font-size: 22px; opacity: .7; margin-right: 2px; font-weight: 400; }
.progress { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 700ms var(--smooth); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 16px; padding: 10px 12px; }
.stat b { display: block; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-2); }
.stat.bad b { color: var(--bad); }
.stat.warn b { color: var(--warn); }
.stat.good b { color: var(--good); }

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.month-nav .mn { font-weight: 700; font-size: 17px; }
.month-nav button.round { width: 38px; height: 38px; }
.month-nav button[disabled] { opacity: .35; pointer-events: none; }

/* ---------- empty / skeleton ---------- */
.empty { text-align: center; padding: 38px 20px; display: grid; gap: 8px; justify-items: center; color: var(--ink-2); }
.empty .em-ico { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); margin-bottom: 4px; }
.empty h3 { color: var(--ink); font-size: 17px; }
.empty p { font-size: 14px; max-width: 280px; }
.sk { height: 62px; border-radius: 18px; background: linear-gradient(90deg, var(--surface), var(--surface-3), var(--surface)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.stale { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 8px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }

/* ---------- QR, receipt, pass ---------- */
.qr { background: #fff; padding: 12px; border-radius: 22px; width: min(78vw, 300px); margin: 0 auto; box-shadow: 0 0 0 1px rgba(13,26,45,.08), var(--shadow); }
.qr svg { display: block; width: 100%; height: auto; }
.code-big { font-family: var(--mono); font-size: 34px; letter-spacing: .22em; font-weight: 700; text-align: center; padding-left: .22em; }
.pass { background: var(--surface); border-radius: 28px; padding: 18px; box-shadow: var(--shadow); display: grid; gap: 14px; position: relative; overflow: hidden; }
.pass::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.pass .who { text-align: center; }
.pass .who h3 { font-size: 22px; font-weight: 700; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }

.receipt { background: var(--surface); border-radius: 22px; padding: 20px 18px; box-shadow: var(--shadow); display: grid; gap: 12px; position: relative; }
.receipt .rhead { display: flex; justify-content: space-between; align-items: center; }
.receipt .amt { font-size: 38px; font-weight: 300; letter-spacing: -.03em; }
.receipt .kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.receipt .kv dt { color: var(--ink-3); }
.receipt .kv dd { margin: 0; text-align: right; font-weight: 600; word-break: break-word; }
.receipt .tear { height: 0; border-top: 2px dashed var(--line); margin: 2px -4px; }
.receipt .seal { display: flex; align-items: center; gap: 12px; }
.receipt .seal .qr { width: 104px; margin: 0; padding: 6px; border-radius: 12px; flex: none; }
.big-check { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; color: #fff; animation: pop var(--spring-t) var(--spring) both; }
.big-check.good { background: linear-gradient(160deg, #3fe0a8, #0c9a74); box-shadow: 0 14px 30px rgba(12,154,116,.4); }
.big-check.bad { background: linear-gradient(160deg, #ff8a7a, #d93a30); box-shadow: 0 14px 30px rgba(217,58,48,.4); }
.big-check.warn { background: linear-gradient(160deg, #ffd27a, #e08a00); box-shadow: 0 14px 30px rgba(224,138,0,.4); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* ---------- timeline ---------- */
.tl { display: grid; gap: 0; }
.tl-i { display: grid; grid-template-columns: 22px 1fr; gap: 10px; position: relative; padding-bottom: 14px; }
.tl-i::before { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 2px; background: var(--line); }
.tl-i:last-child::before { display: none; }
.tl-d { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; color: var(--ink-2); z-index: 1; }
.tl-d.on { background: var(--accent); color: #fff; }
.tl-t { font-size: 14.5px; font-weight: 600; }
.tl-s { font-size: 13px; color: var(--ink-2); }
.bubble { background: var(--surface-2); border-radius: 16px; padding: 9px 12px; font-size: 14.5px; margin-top: 4px; display: inline-block; max-width: 100%; word-break: break-word; }
.bubble.mine { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.photo { width: 100%; border-radius: 18px; display: block; max-height: 320px; object-fit: cover; background: var(--surface-3); }
.thumb { width: 72px; height: 72px; border-radius: 14px; object-fit: cover; background: var(--surface-3); }

/* ---------- scanner ---------- */
.scan { position: relative; border-radius: 28px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; display: grid; place-items: center; }
.scan video { width: 100%; height: 100%; object-fit: cover; }
.scan .frame { position: absolute; inset: 16%; border-radius: 26px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.38), inset 0 0 0 3px rgba(255,255,255,.9); pointer-events: none; }
.scan .line { position: absolute; left: 16%; right: 16%; height: 2px; background: #5df0b3; box-shadow: 0 0 14px #5df0b3; animation: scanline 2s ease-in-out infinite alternate; }
@keyframes scanline { from { top: 18%; } to { top: 80%; } }
.result { border-radius: 26px; padding: 22px 18px; text-align: center; display: grid; gap: 8px; animation: pop var(--spring-t) var(--spring) both; }
.result.good { background: var(--good-bg); }
.result.bad { background: var(--bad-bg); }
.result.warn { background: var(--warn-bg); }
.result h2 { font-size: 24px; }

.hr { height: 1px; background: var(--line); margin: 2px 0; }
.link { color: var(--accent); font-weight: 650; }
.pre { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.badge-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); display: inline-block; }

/* app open/close helpers */
@media (prefers-reduced-motion: reduce) {
  .sheet, .panel, .toast, .result, .big-check { animation-duration: 1ms !important; }
}

/* PIN pad inside light/dark sheets */
.sheet .dots i { box-shadow: inset 0 0 0 2px var(--ink-3); }
.sheet .dots i.on { background: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.sheet .lock-title { color: var(--ink); text-shadow: none; margin-top: 0; }
.sheet .lock-sub { color: var(--ink-2); }
.sheet .dots { margin: 14px 0 8px; }
.sheet .keypad.solid .key.txt { background: none; box-shadow: none; }
.hint-box { background: var(--info-bg); color: var(--ink); border-radius: 16px; padding: 12px 14px; font-size: 13.5px; }
.code-pre { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; white-space: pre; overflow-x: auto; }
.prog { font-variant-numeric: tabular-nums; }

/* settings rows */
.item.set { grid-template-columns: 1fr auto; }
.item.col { grid-template-columns: 1fr; gap: 8px; align-items: stretch; }
.item.col .seg { margin-top: 2px; }
.app .walls { margin-top: 2px; }
.app .walls button.on::after { box-shadow: inset 0 0 0 3px var(--accent); }
.avatar.big { width: 64px; height: 64px; border-radius: 22px; }
.hero-ico { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; margin: 0 auto; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; font-weight: 600; word-break: break-word; }
.sheet .key.blank { background: none; box-shadow: none; border: 0; }
