/* The tenants' pages as a phone app (stage 1): linked from home / new / request / details after portal.css.
   Everything that changes the look is inside the max-width: 700px query and scoped to body.tenant-area (site.js sets
   it only in the tenants' shell - request.html is shared with staff, who keep the normal page). Desktop is unchanged. */

/* Phone-only bits (site.js / tenant.js) never show on a desktop */
.m-bar, .m-sheet, .m-only { display: none; }
.req-list > a.req:last-of-type { border-bottom: 0; }

@media (max-width: 700px) {
  html.tenant-app { font-size: 16px; -webkit-text-size-adjust: 100%; }
  body.tenant-area { font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; -webkit-tap-highlight-color: transparent; }
  body.tenant-area .topbar { display: none; }
  body.tenant-area .m-only { display: block; }
  body.tenant-area #main { padding: 14px 14px calc(28px + env(safe-area-inset-bottom)); padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); max-width: none !important; }
  body.tenant-area #main > h1 { display: none; }          /* the bar carries the title */
  body.tenant-area #main > h1 + p.muted { margin-top: 0; font-size: 14px; }
  body.tenant-area .card { border-radius: 16px; padding: 14px; }
  body.tenant-area .btn { min-height: 44px; border-radius: 12px; font-size: 16px; }
  body.tenant-area .btn.small { min-height: 40px; font-size: 15px; }
  body.tenant-area input, body.tenant-area select, body.tenant-area textarea { font-size: 16px !important; }   /* (no iOS zoom) */
  body.tenant-area .field input, body.tenant-area .field select { min-height: 48px; padding: 10px 12px; border-radius: 12px; }
  body.tenant-area .field textarea { padding: 10px 12px; border-radius: 12px; }

  /* ===== The bar */
  body.tenant-area .m-bar {
    display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 50;
    background: var(--accent); color: var(--on-accent);
    padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
    box-shadow: 0 1px 6px rgba(0, 0, 0, .12);
  }
  .m-back { flex: none; width: 44px; height: 44px; margin-left: -6px; display: grid; place-items: center; color: inherit; border-radius: 50%; }
  .m-back svg { width: 26px; height: 26px; }
  .m-back:active { background: rgba(255, 255, 255, .18); }
  .m-titles { flex: 1; min-width: 0; padding-left: 4px; }
  .m-ws { font-size: 12px; font-weight: 600; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-title { font-size: 20px; font-weight: 750; line-height: 1.2; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-me { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .18);
    color: inherit; font: 700 15px/1 Inter, system-ui, sans-serif; cursor: pointer; padding: 0; }
  .m-me[aria-expanded="true"] { background: rgba(255, 255, 255, .32); }

  /* The initials' sheet */
  body.tenant-area .m-sheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 100; }
  .m-sheet-back { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); }
  .m-sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); color: var(--text); border-radius: 20px 20px 0 0;
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; box-shadow: 0 -4px 20px rgba(0, 0, 0, .2); }
  .m-sheet-panel::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 8px; }
  .m-sheet-who { display: flex; flex-direction: column; padding: 6px 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 15px; }
  .m-sheet-who .muted { font-size: 13px; }
  .m-sheet-panel > a, .m-sheet-panel > button { display: flex; align-items: center; min-height: 52px; padding: 0 8px; font: 500 17px Inter, system-ui, sans-serif;
    color: var(--text); text-decoration: none; background: none; border: 0; border-radius: 12px; text-align: left; cursor: pointer; }
  .m-sheet-panel > a.active { color: var(--accent-strong); font-weight: 650; }
  .m-sheet-panel > a:active, .m-sheet-panel > button:active { background: var(--surface-2); }
  .m-sheet-panel > #mSignOut { color: var(--negative, #b42318); }
  .m-sheet-panel > .m-sheet-cancel { justify-content: center; margin-top: 6px; background: var(--surface-2); font-weight: 600; }

  /* ===== Our requests (home) */
  body.tenant-area .hero { display: block; }
  body.tenant-area .hero h1 { font-size: 22px; margin: 0; }
  body.tenant-area .hero p { margin: 2px 0 0; font-size: 14px; }
  body.tenant-area .hero > .btn { display: none; }       /* the bottom button instead */
  body.tenant-area .cols { display: block; margin-top: 12px !important; }
  body.tenant-area .cols > * + * { margin-top: 12px; }
  body.tenant-area .cols > div > .card + .card { margin-top: 12px; }
  /* the list's card loses its frame: each request is its own card */
  body.tenant-area .card:has(> .req-list) { background: none; border: 0; box-shadow: none; padding: 0; }
  body.tenant-area .card:has(> .req-list) > h2 { font-size: 17px; margin: 4px 2px 8px; }
  .m-seg { display: none; }
  body.tenant-area .m-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
  .m-seg button { min-height: 40px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: 600 15px Inter, system-ui, sans-serif; cursor: pointer; }
  .m-seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
  body.tenant-area .req-list[data-show="open"] > .req[data-closed],
  body.tenant-area .req-list[data-show="closed"] > .req:not([data-closed]) { display: none; }
  body.tenant-area .req-list .m-none-open, body.tenant-area .req-list .m-none-closed { display: none; }
  body.tenant-area .req-list.no-open[data-show="open"] .m-none-open,
  body.tenant-area .req-list.no-closed[data-show="closed"] .m-none-closed { display: block; }
  body.tenant-area .req-list > .req {
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "ref badge" "grow grow"; gap: 4px 10px; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px;
  }
  body.tenant-area .req-list > .req:hover { background: var(--surface); }
  body.tenant-area .req-list > .req:active { background: var(--surface-2); }
  body.tenant-area .req .ref { grid-area: ref; width: auto; font-size: 13px; }
  body.tenant-area .req .ref .m-only { display: inline; }
  body.tenant-area .req > .badge { grid-area: badge; justify-self: end; font-size: 12px; }
  body.tenant-area .req .grow { grid-area: grow; }
  body.tenant-area .req .title { font-size: 16px; font-weight: 700; line-height: 1.3; }
  body.tenant-area .req .meta { display: none; }
  body.tenant-area .req .m-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
  body.tenant-area .req[data-join] { display: block; }
  body.tenant-area .req[data-join] .meta { display: block; }
  body.tenant-area .req[data-join] .row-actions { margin-top: 8px; }

  /* The primary action, fixed at the bottom */
  body.tenant-area #main:has(.m-action) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.tenant-area .m-action { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 10px max(14px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    background: linear-gradient(to top, var(--bg) 70%, transparent); }
  body.tenant-area .m-action .btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 56px; border-radius: 16px; font-size: 17px; font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }

  /* ===== A request */
  body.tenant-area #main > p:has(> a[href="/home.html"]) { display: none; }   /* (the bar's back chevron) */
  body[data-page="request"].tenant-area #main > .hero { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column-reverse; align-items: stretch; gap: 6px; }
  body[data-page="request"].tenant-area #main > .hero h1 { font-size: 19px; font-weight: 700; line-height: 1.3; }
  body[data-page="request"].tenant-area #main > .hero p { font-size: 13px; }
  body[data-page="request"].tenant-area #main > .hero + .card { margin-top: 12px; }
  body.tenant-area .stepper div { font-size: 11px; }
  body.tenant-area .kv { font-size: 15px; gap: 6px 12px; }

  /* Updates as chat bubbles: the workspace's (they carry its badge) on the left, everyone else's on the right. Not the
     email thread (email conversation style - .timeline.mail): its cards stay cards (portal.css) */
  body.tenant-area .timeline:not(.mail) li { border: 0; padding: 4px 0; display: flex; justify-content: flex-end; }
  body.tenant-area .timeline:not(.mail) li > .avatar { display: none; }
  body.tenant-area .timeline:not(.mail) li > .body { flex: 0 1 auto; max-width: 85%; background: var(--accent-soft); color: var(--text); border-radius: 18px 18px 4px 18px; padding: 10px 14px; font-size: 15px; }
  body.tenant-area .timeline:not(.mail) li.theirs { justify-content: flex-start; }
  body.tenant-area .timeline:not(.mail) li.theirs > .body { background: var(--surface); border: 1px solid var(--border); border-radius: 18px 18px 18px 4px; }
  body.tenant-area .timeline:not(.mail) li .body .badge { display: none; }
  body.tenant-area .timeline:not(.mail) li .msg-text { white-space: pre-wrap; margin-top: 2px; }
  body.tenant-area .timeline:not(.mail) li .when { font-size: 12px; margin-top: 4px; }
  body.tenant-area .timeline:not(.mail) li.sys { justify-content: center; }
  body.tenant-area .timeline:not(.mail) li.sys > .body { background: none; border: 0; padding: 2px 8px; max-width: 90%; text-align: center; font-size: 13px; color: var(--muted); }
  body.tenant-area .timeline:not(.mail) li.sys .when { font-size: 11px; margin-top: 0; }
  /* (text conversation style: the page scrolls, not the list - the reply box is pinned below) */
  body.tenant-area .timeline.chat { max-height: none; overflow: visible; }

  /* The reply box, pinned to the bottom */
  body.tenant-area #main:has(#reply) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.tenant-area #reply { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0 !important;
    display: grid; grid-template-columns: 44px 1fr 48px; align-items: end; gap: 8px;
    padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(0, 0, 0, .06); }
  body.tenant-area #reply > .row-actions { display: contents; }
  body.tenant-area #reply .reply-box { grid-column: 2; grid-row: 3; min-height: 44px; height: 44px; max-height: 140px; field-sizing: content;
    border-radius: 22px; padding: 10px 16px; resize: none; line-height: 1.35; }
  body.tenant-area #reply > .file-list { grid-column: 1 / -1; grid-row: 1; }
  body.tenant-area #reply > .form-error { grid-column: 1 / -1; grid-row: 2; }
  body.tenant-area #reply > .form-error:empty, body.tenant-area #reply > .file-list:empty { display: none; }
  body.tenant-area #reply .row-actions > label.btn { grid-column: 1; grid-row: 3; width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%;
    display: grid; place-items: center; font-size: 0; }
  body.tenant-area #reply .row-actions > label.btn::before { content: "📎"; font-size: 20px; }
  body.tenant-area #reply #sendReply { grid-column: 3; grid-row: 3; width: 48px; height: 48px; min-height: 0; padding: 0; border-radius: 50%;
    display: grid; place-items: center; font-size: 0; }
  body.tenant-area #reply #sendReply::before { content: ""; width: 22px; height: 22px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 20.5 21 12 3 3.5l.01 6.6L15 12 3.01 13.9z'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 20.5 21 12 3 3.5l.01 6.6L15 12 3.01 13.9z'/%3E%3C/svg%3E") center / contain no-repeat; }

  /* ===== Log an issue (request-form.js) */
  body.tenant-area #requestForm { padding: 14px; }
  body.tenant-area #requestForm .step-title { font-size: 17px; margin-top: 18px; }
  body.tenant-area .cats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  body.tenant-area .cat { min-height: 84px; border-radius: 14px; padding: 10px 4px; font-size: 13px; font-weight: 600; line-height: 1.2; }
  body.tenant-area .cat .ic { font-size: 26px; }
  body.tenant-area .cat:hover { border-color: var(--border); }
  body.tenant-area .cat.on, body.tenant-area .cat[aria-pressed="true"] { border-color: var(--accent); }
  body.tenant-area .urg { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  body.tenant-area .urg[style] { grid-template-columns: 1fr !important; }   /* (Where is it?: one place a row) */
  body.tenant-area .urg label { min-height: 56px; border-radius: 14px; padding: 12px 8px; display: flex; flex-direction: column; justify-content: center; text-align: center; }
  body.tenant-area .urg[style] label { text-align: left; padding: 12px 14px; }
  body.tenant-area .urg label input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
  body.tenant-area .urg label:has(input:checked) { border-width: 2px; padding: 11px 7px; }
  body.tenant-area .urg[style] label:has(input:checked) { padding: 11px 13px; }
  body.tenant-area .urg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
  body.tenant-area .urg small { font-size: 11.5px; line-height: 1.3; margin-top: 3px; }
  body.tenant-area .urg[style] small { font-size: 13px; }
  body.tenant-area #requestForm .drop { padding: 20px 12px; border-radius: 14px; text-align: center; }
  /* the Send button, stuck to the bottom of the screen */
  body.tenant-area #requestForm > .row-actions:last-child { position: sticky; bottom: 0; z-index: 30; margin: 12px -14px -14px !important;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 16px 16px; }
  body.tenant-area #requestForm > .row-actions:last-child > a.btn { display: none; }   /* (the bar's back chevron) */
  body.tenant-area #requestForm #send { flex: 1; width: 100%; min-height: 56px; border-radius: 16px; font-size: 17px; font-weight: 700; }

  /* ===== Our details: the contacts table scrolls sideways rather than squashing */
  body.tenant-area .card:has(> table.grid) { overflow-x: auto; }
}

/* ===== Sign-in steps (public.js signin at a workspace's address: email -> code / password, Face ID / fingerprint) */
.signin-step[hidden], #passkeyBox[hidden] { display: none; }
.signin-big { width: 100%; justify-content: center; margin-bottom: 8px; }
.code-input { font-size: 1.6rem !important; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; padding-left: .5em; }
.step-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 0; font-size: .9rem; }
.keep-check { font-size: .95rem; }
@media (max-width: 700px) {
  .signin-page { padding: 12px max(12px, env(safe-area-inset-left)) calc(16px + env(safe-area-inset-bottom)); align-items: start; }
  .signin-card .signin-big, .signin-card .ms-btn { min-height: 52px; border-radius: 12px; font-size: 16px; }
  .signin-card .field input { min-height: 48px; font-size: 16px !important; border-radius: 12px; }   /* (16px: no iOS zoom) */
  .signin-card .code-input { min-height: 56px; font-size: 26px !important; }
  .signin-card .step-links .linkish { min-height: 44px; }
  .keep-check input { width: 22px; height: 22px; }
}

/* ===== Your account -> Devices with Face ID / fingerprint (site.js) */
.passkey-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.passkey-row:last-child { border-bottom: 0; }
.passkey-row .grow { flex: 1; min-width: 0; }
@media (max-width: 700px) {
  body.tenant-area #passkeysCard .btn { min-height: 48px; }
  body.tenant-area #addPasskey { width: 100%; min-height: 52px; justify-content: center; }
}

/* ===== App lock (site.js): an installed app back from the background - unlock with Face ID / fingerprint */
.app-lock { position: fixed; inset: 0; z-index: 1000; background: var(--bg, #fff); display: grid; place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.app-lock .lock-box { width: min(360px, 100%); text-align: center; }
.app-lock .lock-icon { font-size: 48px; line-height: 1; margin-bottom: 12px; }
.app-lock h2 { margin: 0 0 6px; }
.app-lock .btn { width: 100%; min-height: 56px; justify-content: center; border-radius: 14px; font-size: 17px; margin-top: 10px; }
.app-lock .linkish { display: inline-block; min-height: 44px; margin-top: 14px; font-size: 16px; }
body.locked > #app { visibility: hidden; }

/* The request's facts (Where / About / Urgency / Visit) - only in the phone layout */
.m-facts { display: none; }
@media (max-width: 700px) {
  body.tenant-area .m-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 12px 0 0; }
  body.tenant-area .m-facts dt { font-size: 12px; color: var(--muted); font-weight: 600; }
  body.tenant-area .m-facts dd { margin: 2px 0 0; font-size: 15px; }
}

/* The menu bar along the bottom (site.js tabs()) - on a phone, installed on the home screen or not.
   The things fixed at the bottom of a page (the reply box, the form's Send bar) sit on top of it; its Report tab
   replaces the home page's "Report an issue" button. */
.m-tabs { display: none; }
@media (max-width: 700px) {
  body.tenant-area { --m-tabs-h: 62px; }
  body.tenant-area .m-tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 0 max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left)); }
  body.tenant-area .m-tabs a { flex: 1; height: var(--m-tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600; -webkit-tap-highlight-color: transparent; }
  body.tenant-area .m-tabs a svg { width: 24px; height: 24px; }
  body.tenant-area .m-tabs a.active { color: var(--accent-strong, var(--accent)); }
  body.tenant-area .m-tabs a.m-tab-main svg { width: 34px; height: 34px; padding: 6px; box-sizing: border-box; border-radius: 50%; background: var(--accent); color: var(--on-accent, #fff); margin-top: -6px; }
  body.tenant-area .m-tabs a.m-tab-main { color: var(--text); }
  body.tenant-area #main { padding-bottom: calc(var(--m-tabs-h) + 24px + env(safe-area-inset-bottom)) !important; }
  body.tenant-area .m-action { display: none; }
  body.tenant-area #main:has(#reply) { padding-bottom: calc(var(--m-tabs-h) + 96px + env(safe-area-inset-bottom)) !important; }
  body.tenant-area #reply { bottom: calc(var(--m-tabs-h) + env(safe-area-inset-bottom)); padding-bottom: 8px; }
  /* (the request form's Send button: at the end of the form, not fixed on screen) */
  body.tenant-area #requestForm > .row-actions:last-child { position: static; margin: 16px 0 0 !important; padding: 0; background: none; border: 0; border-radius: 0; }
}

/* Your account -> Notifications (notifications.js) on a phone: big tap targets */
@media (max-width: 700px) {
  #notifyCard .notify-browser .btn, #notifyCard #notifySave { width: 100%; min-height: 48px; }
  #notifyCard .notify-kinds td:first-child { font-size: .95rem; padding-right: 4px; }
  #notifyCard .notify-kinds th:not(:first-child), #notifyCard .notify-kinds td:not(:first-child) { padding-left: 4px; }
  #notifyCard .notify-tick { min-width: 48px; min-height: 48px; }
  #notifyCard .notify-tick input { width: 24px; height: 24px; }
  #notifyCard .notify-devices .btn { min-height: 44px; }
}
