/* Resident portal (runs inside the app's webview) */
body.resident { background: #fff; min-height: 100vh; }
.r-top-glow {
  position: absolute; inset: 0 0 auto 0; height: 300px; pointer-events: none; z-index: 0;
  background:
  radial-gradient(60% 120% at 0% 0%, rgba(253, 91, 86, .14), transparent 60%),
  radial-gradient(60% 120% at 100% 0%, rgba(161, 168, 249, .30), transparent 60%);
}
[dir="rtl"] .r-top-glow { transform: scaleX(-1); }
.r-header {
  position: sticky; top: 0; z-index: 40; padding-top: var(--safe-t);
  background: rgba(255, 255, 255, .82); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.r-header.scrolled { border-bottom-color: var(--line); }
.r-header-in { max-width: 1080px; margin: 0 auto; height: 60px; padding: 0 12px 0 16px; display: flex; align-items: center; gap: 8px; }
[dir="rtl"] .r-header-in { padding: 0 16px 0 12px; }
.r-header .h-title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-header .h-brand { flex: 1; display: flex; align-items: center; gap: 10px; }
.r-header .h-brand small { font-size: 13px; color: var(--muted); font-weight: 500; padding-inline-start: 10px; border-inline-start: 1px solid var(--line-2); }
.r-header .h-actions { display: flex; align-items: center; gap: 4px; }
.r-desk-nav { display: none; gap: 4px; }
@media (max-width: 420px) {
  .r-header .h-brand small { display: none; }
}
.r-desk-nav a { padding: 8px 14px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.r-desk-nav a:hover { background: var(--chip); }
.r-desk-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-50); }
.r-main { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 8px 16px calc(100px + var(--safe-b)); }
.r-main.narrow { max-width: 680px; }
/* Bottom tab bar (mirrors the app) */
.r-tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 50; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px 8px calc(6px + var(--safe-b));
}
.r-tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; color: #8C8C8C; font-size: 12px; font-weight: 500; }
.r-tabbar a .icon { width: 24px; height: 24px; }
.r-tabbar a[aria-current="page"] { color: var(--brand); font-weight: 600; }
@media (min-width: 900px) {
  .r-tabbar { display: none; }
  .r-desk-nav { display: flex; }
  .r-main { padding-bottom: 64px; padding-top: 16px; }
  .toasts { bottom: 32px; }
}
/* Home */
.hello { padding: 12px 0 20px; }
.hello h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.hello p { color: var(--muted); margin-top: 4px; font-size: 15px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 28px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow-sm); display: block; color: inherit; }
.stat:hover { border-color: var(--line-2); }
.stat .s-l { font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.3; }
.stat .s-v { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; line-height: 1.1; }
.stat .s-v small { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat.owed .s-v { color: var(--red); }
.svc-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 32px; }
.svc {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--r-lg);
  border: 1px solid var(--line); background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s, transform .1s;
}
.svc:hover { border-color: #D5D9FB; box-shadow: var(--shadow); }
.svc:active { transform: scale(.99); }
.svc .sec-ic { border-radius: 14px; }
.svc .svc-t { font-weight: 700; font-size: 16px; }
.svc .svc-d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.svc .svc-x { flex: 1; min-width: 0; }
.svc .chev { color: #B5B5BD; }
.sec-ic { display: inline-grid; place-items: center; border-radius: 12px; flex: none; }
.sec-ic .icon { width: 22px; height: 22px; }
@media (min-width: 640px) {
  .svc-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .svc-grid { grid-template-columns: repeat(3, 1fr); }
  .svc { flex-direction: column; align-items: flex-start; padding: 20px; min-height: 170px; }
  .svc .chev { display: none; }
  .svc .sec-ic { width: 48px !important; height: 48px !important; }
  .hello h1 { font-size: 32px; }
}
/* Request list */
.req-list { display: grid; gap: 10px; }
.req-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--r-lg);
  background: #fff; border: 1px solid var(--line); color: inherit; transition: border-color .15s, box-shadow .15s;
}
.req-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.req-card .rc-x { flex: 1; min-width: 0; }
.req-card .rc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.req-card .rc-t { font-weight: 600; font-size: 15px; line-height: 1.3; }
.req-card .rc-s { font-size: 13px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.req-card .rc-m { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 8px; align-items: center; }
.req-card .rc-m .dot { width: 3px; height: 3px; background: currentColor; border-radius: 50%; }
.req-card .owed-tag { color: var(--red); font-weight: 700; }
@media (min-width: 900px) {
  .req-list.two { grid-template-columns: 1fr 1fr; }
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.filter-row { margin-bottom: 16px; }
/* Form page */
.form-wrap { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
.form-wrap > *, #form-body > * { min-width: 0; }
.form-hero { display: flex; gap: 14px; align-items: center; margin: 4px 0 4px; }
.form-hero h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.form-hero p { color: var(--muted); font-size: 14px; }
.who {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r);
  background: var(--bg); border: 1px solid var(--line);
}
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.who .w-l { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.who .w-n { font-weight: 600; font-size: 14px; }
.who .w-e { font-size: 13px; color: var(--ink-2); }
.form-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; }
.form-card + .form-card { margin-top: 0; }
.fieldset-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.submit-bar {
  position: sticky; bottom: 0; z-index: 30; margin: 0 -16px; padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, #fff 70%, rgba(255,255,255,0));
}
body.resident.on-form .r-tabbar { display: none; }
body.resident.on-form .r-main { padding-bottom: 24px; }
@media (min-width: 900px) {
  .submit-bar { position: static; margin: 0; padding: 0; background: none; }
}
/* Detail */
.detail-head { padding: 18px; border-radius: var(--r-lg); background: var(--bg); border: 1px solid var(--line); }
.detail-head .dh-row { display: flex; align-items: center; gap: 12px; }
.detail-head h1 { font-size: 20px; font-weight: 700; line-height: 1.25; }
.detail-head .dh-sec { font-size: 13px; color: var(--muted); }
.detail-grid { display: grid; gap: 16px; margin-top: 16px; }
@media (min-width: 900px) {
  .detail-grid { grid-template-columns: 1.4fr 1fr; align-items: start; }
}
.slots-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.slots-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; background: var(--chip); border-radius: 8px; font-size: 13.5px; }
.owed-big { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--red-50); }
.owed-big .ob-l { font-weight: 700; color: var(--red); font-size: 14px; }
.owed-big .ob-v { font-weight: 800; color: var(--red); font-size: 22px; white-space: nowrap; }
.owed-big.zero { background: var(--mint-50); }
.owed-big.zero .ob-l, .owed-big.zero .ob-v { color: var(--mint); }
/* Profile */
.p-head { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: var(--r-xl); background: linear-gradient(135deg, #EEF1FF, #FFF2F1); margin: 8px 0 20px; }
.p-head .avatar { width: 64px; height: 64px; font-size: 22px; box-shadow: 0 0 0 4px #fff; }
.p-head h1 { font-size: 20px; font-weight: 700; }
.p-head p { font-size: 14px; color: var(--ink-2); }
.p-grid { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .p-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .p-grid .span-2 { grid-column: span 2; }
}
.p-card { padding: 18px; border-radius: var(--r-lg); border: 1px solid var(--line); background: #fff; }
.p-card-h { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.p-card-h h2 { font-size: 16px; font-weight: 700; flex: 1; }
.p-card-h .p-total { text-align: end; }
.p-card-h .p-total b { display: block; font-size: 22px; line-height: 1; }
.p-card-h .p-total span { font-size: 11.5px; color: var(--muted); }
.mini-list { display: grid; gap: 8px; margin-top: 16px; }
.mini { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r); background: var(--bg); font-size: 13.5px; color: inherit; }
.mini .m-x { flex: 1; min-width: 0; }
.mini .m-t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .m-s { font-size: 12px; color: var(--muted); }
.mini .m-amt { font-weight: 700; text-align: end; white-space: nowrap; }
.mini .m-amt small { display: block; font-size: 11px; font-weight: 700; }
.mini .m-amt.owed { color: var(--red); }
.mini .m-amt.zero { color: var(--mint); }
.rings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.decision { padding: 12px 14px; border-radius: var(--r); font-size: 13.5px; }
.decision b { display: block; margin-bottom: 2px; }
/* Notifications */
.n-list { display: grid; }
.n-item { display: flex; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); color: inherit; }
.n-item.unread { background: linear-gradient(to right, var(--brand-50), transparent 70%); border-radius: 12px; padding-inline: 10px; border-bottom-color: transparent; margin-bottom: 1px; }
[dir="rtl"] .n-item.unread { background: linear-gradient(to left, var(--brand-50), transparent 70%); }
.n-item .n-x { flex: 1; min-width: 0; }
.n-item .n-t { font-weight: 600; font-size: 14px; }
.n-item .n-b { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.n-item .n-m { font-size: 12px; color: var(--muted); margin-top: 6px; }
/* Sign in with contract ID */
.si-main { display: grid; place-items: start center; padding-top: 32px; }
.si-card { width: 100%; max-width: 420px; display: grid; gap: 16px; padding: 28px 22px; border-radius: var(--r-xl); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.si-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.si-card > p.muted { font-size: 14px; margin-top: -8px; }
.si-ic { width: 52px; height: 52px; border-radius: 16px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; }
.si-ic .icon { width: 26px; height: 26px; }
.si-input { font-size: 18px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; text-align: center; }
.si-input::placeholder { letter-spacing: .06em; font-weight: 500; }
.si-help { display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; }
.si-help .icon { margin-top: 2px; }
@media (min-width: 640px) {
  .si-main { padding-top: 64px; }
  .si-card { padding: 36px 32px; }
}
/* Profile identity */
.p-head { flex-wrap: wrap; }
.p-id { flex: 1; min-width: 0; }
.p-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.p-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; background: rgba(255,255,255,.75); font-size: 12.5px; color: var(--ink-2); }
.p-chip b { color: var(--ink); font-weight: 700; }
.p-chip .icon { color: var(--brand); }
.p-out { background: #fff; }
@media (max-width: 520px) {
  .p-out { width: 100%; }
}
/* Pass key (matches the app's PIN screen: 6 cells + keypad) */
.pk-card { position: relative; text-align: center; justify-items: center; }
.pk-card > p.muted { margin-top: -8px; }
.pk-card .si-ic { margin: 0 auto; }
.pk-back { position: absolute; top: 14px; inset-inline-start: 10px; }
.pk-steps { display: flex; gap: 6px; justify-content: center; }
.pk-steps span { width: 28px; height: 4px; border-radius: 2px; background: var(--line-2); }
.pk-steps span.on { background: var(--brand); }
#pk-pad { width: 100%; display: grid; gap: 18px; }
.pin-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.pin-cells { display: grid; grid-template-columns: repeat(6, minmax(0, 46px)); gap: 8px; }
.pin-cell {
  aspect-ratio: 46 / 52; border-radius: 10px; border: 1.5px solid var(--line-2); background: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 700; color: var(--ink); transition: border-color .15s, background .15s;
}
.pin-cell.filled { border-color: #C9CCF8; background: var(--brand-50); }
.pin-cell.next { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.pin-cells.shake { animation: shake .35s; }
.pin-cells.shake .pin-cell { border-color: var(--red); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); }; }
.pin-eye { color: var(--muted); }
[dir="rtl"] .pk-err { justify-content: center; min-height: 0; text-align: center; }
.pk-rules { list-style: none; margin: -4px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); text-align: start; width: 100%; }
.pk-rules li::before { content: "•"; margin-inline-end: 6px; color: var(--brand); }
.pk-links { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.si-link { border: 0; background: none; color: var(--brand); font-weight: 600; font-size: 13.5px; padding: 6px 8px; border-radius: 8px; }
.si-link:hover { background: var(--brand-50); }
.pk-input { font-size: 20px; letter-spacing: .4em; text-align: center; }
.p-acts { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 520px) {
  .p-acts { width: 100%; }
  .p-acts .p-out { flex: 1; }
}
/* ---------- Assigned technician (maintenance) ---------- */
.tech-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--yellow-50); }
.tech-card .tc-ic { width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #A46F00; display: grid; place-items: center; flex: none; }
.tech-card .tc-x { flex: 1; min-width: 0; display: grid; }
.tech-card small { font-size: 12px; color: var(--muted); }
.tech-card b { font-size: 15px; }
.tech-card .tc-x span { font-size: 13px; color: var(--muted); text-align: start; }
.tech-card .icon-btn { flex: none; background: #fff; }
.rc-tech { display: inline-flex; align-items: center; gap: 4px; }
.rc-tech .icon-sm { width: 13px; height: 13px; }
/* ---------- Motion (resident portal) ---------- */
.svc, .req-card, .n-item { transition: box-shadow .2s, border-color .2s, transform .2s var(--ease-out); }
.svc:hover, .req-card:hover { transform: translateY(-2px); }
.svc:active, .req-card:active { transform: scale(.985); }
/* pass key cells pop as digits are typed */
.pin-cells > * { transition: border-color .15s, transform .15s var(--ease-spring), background .15s; }
@media (prefers-reduced-motion: reduce) {
  .svc:hover, .req-card:hover { transform: none; }
}
/* ---------- Contracts on the profile; the cancellation service when one already exists ---------- */
.p-contracts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.p-contract { padding: 10px 12px; border-radius: 12px; background: var(--chip); display: grid; gap: 2px; }
.p-contract.cur { background: var(--brand-50); }
.p-contract small { font-size: 12.5px; color: var(--muted); }
.p-cur { display: inline-block; margin-inline-start: 6px; padding: 1px 8px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; }
.svc.svc-done { opacity: .85; background: var(--chip); }

/* Pass key: the real field sits over the 6 cells (invisible), so taps and typing go straight into it */
.pin-cells { position: relative; cursor: text; }
.pin-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; margin: 0; font-size: 16px; color: transparent; background: transparent; caret-color: transparent; letter-spacing: 40px; }
.pin-input:disabled { cursor: not-allowed; }
.pin-hint { margin: 10px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }
