/**
 * Portal Sesipa — padrões globais mobile / PWA
 *
 * Primitivos reutilizáveis (usar nestas classes; evitar CSS local):
 *   .portal-toolbtn          botão ícone 44×44
 *   .portal-unread-badge     badge de não lidas
 *   .portal-sr-only          esconde visualmente (acessível a leitores)
 *   .portal-shell            card/shell de tela
 *   .portal-action-list      lista de serviços (thumb zone)
 *   .portal-section-title    título de seção
 *
 * Modos de body:
 *   .portal-home-ativo       home (wizard oculto) — header limpo
 *   .morador-ativo           área do locatário
 */

:root {
  --portal-brand: var(--sesipa-primary, #ff6b35);
  --portal-brand-dk: var(--sesipa-primary-hover, #e55a28);
  --portal-ink: var(--text, #1a3a52);
  --portal-ink-soft: var(--muted, rgba(26, 58, 82, 0.72));
  --portal-surface: var(--surface, #ffffff);
  --portal-bg: var(--bg, #e8edf2);
  --portal-radius-lg: var(--r-lg, 16px);
  --portal-radius-xl: var(--r-xl, 20px);
  --portal-shadow-soft: var(--shadow-md, 0 8px 32px rgba(26, 58, 82, 0.1));
  --portal-shadow-lift: var(--shadow-lg, 0 12px 40px rgba(26, 58, 82, 0.14));
  --portal-touch: 44px;
}

/* Evita zoom automático no iOS ao focar inputs */
@media (max-width: 768px) {
  .portal-app input,
  .portal-app select,
  .portal-app textarea,
  .portal-app .form-control {
    font-size: 16px !important;
  }
}

.portal-app {
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ── Screen-reader only (input file, labels auxiliares) ── */
.portal-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  clip-path: inset(50%) !important;
}

/* ── Toolbtn (padrão global de ícone 44px) ─────────── */
.portal-toolbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: var(--portal-touch);
  min-height: var(--portal-touch);
  padding: 0 12px;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, #d8e0ea);
  background: var(--surface-soft, #f4f7fa);
  color: var(--portal-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.portal-toolbtn i {
  font-size: 18px;
  line-height: 1;
}

.portal-toolbtn:hover {
  background: var(--portal-surface);
  border-color: var(--border, #c5d0dc);
}

.portal-toolbtn:active {
  transform: scale(0.97);
}

.portal-toolbtn:focus-visible {
  outline: 2px solid var(--portal-brand);
  outline-offset: 2px;
}

.portal-toolbtn--brand {
  color: var(--portal-brand);
  border-color: rgba(255, 107, 53, 0.35);
  background: #fff7ed;
}

.portal-toolbtn--brand:hover {
  border-color: var(--portal-brand);
  background: #ffedd5;
}

.portal-toolbtn--primary {
  color: #fff;
  border-color: var(--portal-brand);
  background: var(--portal-brand);
}

.portal-toolbtn--primary:hover {
  border-color: var(--portal-brand-dk);
  background: var(--portal-brand-dk);
  color: #fff;
}

.portal-toolbtn--primary:disabled {
  opacity: 0.5;
  cursor: wait;
}

.portal-toolbtn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--portal-ink-soft);
}

.portal-toolbtn--icon {
  padding: 0;
  width: var(--portal-touch);
}

.portal-toolbtn__label {
  display: none;
}

@media (min-width: 480px) {
  .portal-toolbtn__label {
    display: inline;
  }
}

.portal-unread-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 1;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #25d366;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--portal-surface);
  pointer-events: none;
  box-sizing: border-box;
}

.portal-unread-badge.is-hidden {
  display: none;
}

/* ── Header do portal (único em todas as etapas) ───── */
.app-header {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-header .header-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Home: esconde contador de etapas do wizard */
body.portal-home-ativo .step-counter,
body.portal-home-ativo .step-title-sm,
body.portal-home-ativo .progress-track {
  display: none !important;
}

html.portal-standalone .portal-pwa-body {
  padding-top: 0;
}

html.portal-standalone .app-header {
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}

/* ── Shell / lista de ações ────────────────────────── */
.portal-shell {
  border-radius: var(--portal-radius-xl);
  overflow: hidden;
  background: var(--portal-surface);
  border: 1px solid rgba(26, 58, 82, 0.07);
  box-shadow: var(--portal-shadow-lift);
}

.portal-shell__body {
  padding: 16px;
  background: linear-gradient(180deg, #f4f6f9 0%, #eef2f6 100%);
}

.portal-section-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--portal-ink);
  margin: 0 0 12px;
  padding: 0 2px;
}

.portal-action-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--portal-surface);
  border-radius: var(--portal-radius-lg);
  border: 1px solid rgba(26, 58, 82, 0.08);
  box-shadow: 0 4px 20px rgba(26, 58, 82, 0.06);
  overflow: hidden;
}

.portal-action-row {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--border-subtle, #e1e4e8);
  background: var(--portal-surface);
  text-decoration: none;
  color: var(--portal-ink);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 0.18s ease;
}

.portal-action-row:last-child {
  border-bottom: none;
}

.portal-action-row:active {
  background: var(--surface-soft, #f4f7fa);
}

.portal-action-row:focus-visible {
  outline: 3px solid rgba(255, 107, 53, 0.45);
  outline-offset: -3px;
}

.portal-action-row__ico {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  background: var(--surface-soft, #f1f5f9);
  color: var(--portal-brand);
}

.portal-action-row__ico--ok {
  background: #ecfdf5;
  color: #15803d;
}

.portal-action-row__ico--warn {
  background: #fff7ed;
  color: #c2410c;
}

.portal-action-row__ico--info {
  background: #eff6ff;
  color: #1d4ed8;
}

.portal-action-row__ico--brand {
  background: #fff7ed;
  color: var(--portal-brand);
}

.portal-action-row--cta .portal-action-row__lbl {
  color: var(--portal-ink);
}

.portal-action-row--cta:active {
  background: color-mix(in srgb, var(--portal-brand) 8%, var(--portal-surface));
}

.portal-action-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portal-action-row__lbl {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--portal-ink);
}

.portal-action-row__hint {
  font-size: 13px;
  font-weight: 500;
  color: var(--portal-ink-soft);
  line-height: 1.35;
}

.portal-action-row__chev {
  flex-shrink: 0;
  font-size: 15px;
  color: var(--muted, #94a3b8);
  opacity: 0.85;
}

@media (max-width: 480px) {
  .portal-action-row {
    min-height: 76px;
    padding-top: 14px;
    padding-bottom: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-toolbtn,
  .portal-action-row {
    transition: none;
  }
  .portal-toolbtn:active {
    transform: none;
  }
}

/* ── Home app (candidato aprovado + locatário) ─────── */
body.portal-home-ativo {
  background: var(--portal-bg);
  min-height: 100dvh;
}

body.portal-home-ativo .main {
  background: transparent;
  padding-left: 12px;
  padding-right: 12px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

body.portal-home-ativo #imovelBar {
  display: none !important;
}

.home-container.home-container--app {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.home-container--app .home-hero {
  text-align: left;
  padding: 12px 0 0;
}

/* Locatário: sem vão entre header e conteúdo (fundo escuro/cinza desnecessário) */
body.morador-ativo {
  background: var(--portal-surface);
}

body.morador-ativo .main {
  padding-top: 0;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

body.morador-ativo .home-container--app .home-hero,
body.morador-ativo .home-hero-morador-wrap {
  padding: 0;
  margin: 0;
}

body.morador-ativo .morador-app-shell.portal-shell {
  border-radius: 0;
  border: none;
  box-shadow: none;
  border-bottom: 1px solid rgba(26, 58, 82, 0.06);
}

/* Shell do candidato (pré-morador): reusa .portal-shell */
#homeHeroDefaultWrap.portal-shell {
  text-align: center;
  padding: 28px 20px 20px;
  background: var(--portal-surface);
}

#homeHeroDefaultWrap.portal-shell .success-icon {
  font-size: 48px;
  margin-bottom: 10px;
  color: var(--portal-brand);
  line-height: 1;
}

#homeHeroDefaultWrap.portal-shell h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  color: var(--portal-ink);
}

#homeHeroDefaultWrap.portal-shell > p {
  font-size: 15px;
  line-height: 1.5;
  color: var(--portal-ink-soft);
  margin: 0 auto;
  max-width: 36ch;
}

#homeHeroDefaultWrap.portal-shell .home-etapa-pipeline {
  margin-top: 20px;
  text-align: center;
}

#homeHeroDefaultWrap.portal-shell #homeContratoAviso {
  margin-top: 16px;
  max-width: 36ch;
}

#homeHeroDefaultWrap.portal-shell .morador-contrato-mount {
  margin-top: 18px;
  text-align: left;
}

#homeHeroDefaultWrap.portal-shell .morador-contrato-mount:not(:has(#homeContratoEntryList:not([hidden]))) {
  display: none;
}

/* Trilho pós-aprovação: Análise → Vistoria → Contrato */
.home-etapa-pipeline {
  margin: 0;
  padding: 0;
  width: 100%;
}

.home-etapa-pipeline[hidden] {
  display: none !important;
}

.home-etapa-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding: 4px 8px 0;
}

.home-etapa-rail {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  min-width: min(100%, 280px);
  max-width: 360px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.home-etapa-rail::before {
  content: '';
  position: absolute;
  top: 11px;
  left: 18%;
  right: 18%;
  height: 2px;
  background: var(--border-subtle, #d8e0ea);
  border-radius: 1px;
  z-index: 0;
}

.home-etapa-rail > li {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 4.5rem;
  max-width: 7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--portal-ink-soft);
}

.home-etapa-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.home-etapa-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.home-etapa-rail > li.home-etapa-done .home-etapa-ico {
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  font-size: 14px;
  font-weight: 700;
}

.home-etapa-ring {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--portal-brand);
  box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.2);
}

.home-etapa-ring--muted {
  background: var(--portal-surface);
  border: 2px solid var(--border-subtle, #d8e0ea);
  box-shadow: none;
  width: 10px;
  height: 10px;
}

.home-etapa-rail > li.home-etapa-current {
  color: var(--portal-ink);
}

.home-etapa-rail > li.home-etapa-current .home-etapa-label {
  font-weight: 700;
  color: var(--portal-ink);
}

.home-etapa-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.home-etapa-now {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--portal-brand-dk);
  line-height: 1.2;
}

@media (min-width: 400px) {
  .home-etapa-rail {
    max-width: 380px;
    gap: 8px;
  }
}

/* Locatário: saudação amigável (sem avatar/foto) */
.home-hero-morador-wrap {
  padding: 0;
}

.morador-app-shell.portal-shell .morador-app-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 16px 18px 4px;
  background: var(--portal-surface);
  color: var(--portal-ink);
}

.morador-app-user {
  min-width: 0;
  width: 100%;
}

.morador-app-greeting {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--portal-ink);
  text-wrap: pretty;
}

.morador-app-greeting__lead {
  font-weight: 500;
  color: var(--portal-ink-soft);
}

.morador-app-greeting__lead::after {
  content: '\00a0';
}

.morador-app-role {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--portal-ink-soft);
}

.morador-app-live-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff7ed;
  border: 1px solid rgba(255, 107, 53, 0.25);
  flex-shrink: 0;
}

.morador-live-tag-value {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--portal-brand-dk);
}

.morador-live-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--portal-brand);
}

.morador-app-live-tag.is-active .morador-live-pulse {
  background: #22c55e;
}

.morador-unit-card {
  padding: 4px 18px 16px;
  background: var(--portal-surface);
}

.morador-unit-line {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--portal-ink);
  text-wrap: pretty;
}

.morador-unit-kicker {
  font-size: 15px;
  font-weight: 600;
  color: var(--portal-ink-soft);
  white-space: nowrap;
}

.morador-unit-sep {
  font-weight: 600;
  color: var(--portal-ink-soft);
  white-space: nowrap;
}

#moradorUnitLine {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Aliases de transição (markup legado → padrões globais) */
.morador-app-scroll {
  padding: 8px 16px 20px;
  background: var(--portal-bg);
}

.morador-app-section-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--portal-ink);
  margin: 0 0 12px;
  padding: 0 2px;
}

.morador-action-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--portal-surface);
  border-radius: var(--portal-radius-lg);
  border: 1px solid rgba(26, 58, 82, 0.08);
  box-shadow: 0 4px 20px rgba(26, 58, 82, 0.06);
  overflow: hidden;
}

.morador-action-row {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--border-subtle, #e1e4e8);
  background: var(--portal-surface);
  text-decoration: none;
  color: var(--portal-ink);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.morador-action-row:last-child {
  border-bottom: none;
}

.morador-action-row:active {
  background: var(--surface-soft, #f4f7fa);
}

.morador-app-cell-ico {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  background: var(--surface-soft, #f1f5f9);
  color: var(--portal-brand);
}

.morador-app-cell--vistoria .morador-app-cell-ico {
  background: #ecfdf5;
  color: #15803d;
}

.morador-app-cell--contest .morador-app-cell-ico {
  background: #fff7ed;
  color: #c2410c;
}

.morador-app-cell--relatorio .morador-app-cell-ico {
  background: #eff6ff;
  color: #1d4ed8;
}

.morador-app-cell-lbl {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--portal-ink);
}

.morador-app-cell-hint {
  font-size: 13px;
  font-weight: 500;
  color: var(--portal-ink-soft);
  line-height: 1.35;
}

.morador-action-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.morador-action-row__chev {
  flex-shrink: 0;
  font-size: 15px;
  color: var(--muted, #94a3b8);
}

.morador-chat-badge {
  /* preferir .portal-unread-badge */
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 1;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #25d366;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--portal-surface);
  pointer-events: none;
  box-sizing: border-box;
}

.morador-chat-badge.is-hidden {
  display: none;
}

body.morador-ativo #statusBadgeWrap,
body.morador-ativo #homeAguardandoContent,
body.morador-ativo #homeCtaRow {
  display: none !important;
}

body.morador-ativo .main {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.morador-contrato-mount:empty {
  display: none;
}

.portal-action-list .portal-action-row[hidden] {
  display: none !important;
}

@media (max-width: 480px) {
  body.portal-home-ativo .main {
    padding-left: 0;
    padding-right: 0;
  }

  body.portal-home-ativo .portal-shell,
  body.portal-home-ativo .morador-app-shell {
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }

  .home-hero-morador-wrap,
  .home-container--app .home-hero {
    padding-left: 0;
    padding-right: 0;
  }
}

html.portal-standalone body.portal-home-ativo:not(.morador-ativo) {
  background: var(--portal-bg);
}

html.portal-standalone body.morador-ativo {
  background: var(--portal-bg, #e8edf2);
}

html.portal-standalone body.morador-ativo .app-header {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: var(--portal-surface, #fff);
}

/* ── Loading (app shell) ───────────────────────────── */
.portal-loading-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: min(72vh, 520px);
  padding: 32px 24px;
  text-align: center;
}

.portal-loading-track {
  width: min(160px, 56vw);
  height: 3px;
  border-radius: 99px;
  background: #e2e8f0;
  overflow: hidden;
  margin-bottom: 20px;
}

.portal-loading-bar {
  display: none;
}

.portal-loading-shell p {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--portal-ink-soft);
}

#emptyState.portal-empty-error .portal-loading-track {
  display: none;
}

#emptyState.portal-empty-error .portal-loading-shell {
  min-height: auto;
  padding-top: 48px;
}

#emptyState.portal-empty-error #emptyMsg {
  font-size: 15px;
  line-height: 1.55;
  color: var(--portal-ink-soft);
  max-width: 320px;
}

@media (prefers-reduced-motion: reduce) {
  .portal-loading-bar {
    animation: none;
    width: 100%;
  }
}

/* ── Login como app ────────────────────────────────── */
body.portal-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--portal-bg);
}

body.portal-login .login-app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
}

body.portal-login .login-brand {
  text-align: center;
  padding: 16px 0 24px;
}

body.portal-login .login-brand img {
  max-width: 148px;
  height: auto;
}

body.portal-login .login-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: var(--portal-radius-lg);
  padding: 28px 24px 32px;
  box-shadow: var(--portal-shadow-soft);
  border: 1px solid rgba(26, 58, 82, 0.06);
}

body.portal-login .login-card form {
  margin-top: auto;
}

html.portal-standalone body.portal-login .login-app-shell {
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}

/* Barra de navegação do formulário */
.nav-wrapper {
  background: rgba(255, 255, 255, 0.96) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(26, 58, 82, 0.08) !important;
  box-shadow: 0 -8px 32px rgba(26, 58, 82, 0.08);
}

html.portal-standalone .portal-pwa-install {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* ── iOS: instalar na tela inicial ─────────────────── */
.portal-ios-sheet {
  position: fixed;
  inset: 0;
  z-index: 10002;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s;
}

.portal-ios-sheet.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.portal-ios-sheet__panel {
  width: 100%;
  max-width: 480px;
  background: var(--portal-surface);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.15);
}

.portal-ios-sheet.is-open .portal-ios-sheet__panel {
  transform: translateY(0);
}

.portal-ios-sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #e2e8f0;
  margin: 0 auto 16px;
}

.portal-ios-sheet h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--portal-ink);
}

.portal-ios-sheet p {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--portal-ink-soft);
}

.portal-ios-steps {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-ios-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--portal-ink);
}

.portal-ios-steps__num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 107, 53, 0.12);
  color: var(--portal-brand-dk);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portal-ios-sheet__btn {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--portal-brand);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.portal-ios-sheet__btn:active {
  background: var(--portal-brand-dk);
}

/* ── Chamados (chat full-screen) ─────────────────────── */
.chamado-dialog {
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100dvh;
  inset: 0;
  background: var(--portal-surface, #fff);
  overflow: hidden;
}

.chamado-dialog::backdrop {
  background: rgba(26, 58, 82, 0.45);
}

.chamado-dialog-inner {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--portal-bg, #e8edf2);
}

.chamado-dialog-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 12px 10px;
  background: var(--portal-surface);
  border-bottom: 1px solid var(--border-subtle, #d8e0ea);
}

.chamado-close {
  flex-shrink: 0;
  min-width: var(--portal-touch);
  padding: 0;
}

.chamado-close i {
  font-size: 20px;
}

.chamado-head-text {
  flex: 1;
  min-width: 0;
}

.chamado-head-text h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--portal-ink);
  line-height: 1.25;
  text-wrap: balance;
}

.chamado-head-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chamado-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--portal-ink-soft);
  background: rgba(26, 58, 82, 0.06);
  border: 1px solid rgba(26, 58, 82, 0.08);
  line-height: 1.35;
}

.chamado-state-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3d9a6a;
  opacity: 0.85;
  flex-shrink: 0;
}

.chamado-state-badge.is-hidden {
  display: none;
}

.chamado-head-text p {
  margin: 3px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--portal-ink-soft);
  line-height: 1.35;
}

.chamado-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 20px;
  padding: 0 14px 10px;
  background: var(--portal-surface);
  border-bottom: 1px solid var(--border-subtle, #d8e0ea);
}

.chamado-tabs.is-hidden {
  display: none;
}

.chamado-tab {
  flex: none;
  min-height: 36px;
  padding: 6px 2px;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--portal-ink-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.chamado-tab.is-active {
  color: var(--portal-ink);
  border-bottom-color: var(--portal-brand);
}

.chamado-tab:active {
  opacity: 0.85;
}

.chamado-tab:focus-visible {
  outline: 2px solid var(--portal-brand);
  outline-offset: 2px;
}

.chamado-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chamado-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.chamado-panel.is-active {
  display: flex;
}

.chamado-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 14px 10px;
  background: var(--surface-soft, #f4f7fa);
}

.chamado-msgs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chamado-day {
  align-self: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--portal-ink-soft);
  background: var(--portal-surface);
  padding: 5px 12px;
  border-radius: 999px;
  margin: 10px 0 6px;
  box-shadow: var(--portal-shadow-soft, 0 4px 16px rgba(26, 58, 82, 0.08));
}

.chamado-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

.chamado-msg.msg-candidato {
  align-self: flex-end;
  background: var(--portal-brand);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 12px rgba(255, 107, 53, 0.25);
}

.chamado-msg.msg-equipe {
  align-self: flex-start;
  background: var(--portal-surface);
  color: var(--portal-ink);
  border-bottom-left-radius: 6px;
  box-shadow: var(--portal-shadow-soft, 0 4px 16px rgba(26, 58, 82, 0.08));
}

.chamado-msg.msg-sistema {
  align-self: center;
  max-width: 94%;
  background: transparent;
  color: var(--portal-ink-soft);
  font-size: 12px;
  text-align: center;
  padding: 6px 10px;
  line-height: 1.45;
}

.chamado-msg-meta {
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
  margin-bottom: 4px;
}

.chamado-msg.msg-candidato .chamado-msg-meta {
  color: rgba(255, 255, 255, 0.88);
}

.chamado-msg.msg-equipe .chamado-msg-meta {
  color: var(--portal-ink-soft);
}

.chamado-msg-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chamado-msg-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  transition: background 0.2s ease;
}

.chamado-msg.msg-equipe .chamado-msg-link {
  background: var(--portal-brand);
  color: #fff;
}

.chamado-msg.msg-equipe .chamado-msg-link:hover {
  background: var(--portal-brand-dk);
}

.chamado-msg.msg-sistema .chamado-msg-link {
  background: var(--portal-surface);
  color: var(--portal-brand-dk);
  border: 1px solid var(--border-subtle, #d8e0ea);
}

.chamado-empty,
.chamado-loading {
  text-align: center;
  color: var(--portal-ink-soft);
  font-size: 14px;
  line-height: 1.5;
  padding: 52px 20px;
  margin: 0;
  max-width: 22rem;
  margin-inline: auto;
}

.chamado-empty-sub {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.9;
}

.chamado-empty-ico {
  font-size: 42px;
  color: var(--portal-brand);
  opacity: 0.32;
  display: block;
  margin-bottom: 14px;
}

.chamado-hist-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

.chamado-hist-card {
  background: var(--portal-surface);
  border-radius: var(--portal-radius-lg);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--portal-shadow-soft);
}

.chamado-hist-card summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--portal-ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chamado-hist-card summary::-webkit-details-marker {
  display: none;
}

.chamado-hist-card summary::after {
  content: '\F282';
  font-family: 'bootstrap-icons';
  font-size: 14px;
  color: var(--portal-ink-soft);
}

.chamado-hist-card[open] summary::after {
  content: '\F286';
}

.chamado-hist-card .chamado-msgs {
  padding: 0 12px 14px;
  max-height: 260px;
  overflow-y: auto;
}

.chamado-hist-badge {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--portal-ink-soft);
  background: var(--surface-soft, #f4f7fa);
  padding: 4px 9px;
  border-radius: 999px;
}

.chamado-assunto-chips {
  display: none;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chamado-assunto-chips.is-visible {
  display: flex;
}

.chamado-assunto-chips::-webkit-scrollbar {
  display: none;
}

.chamado-chip {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle, #d8e0ea);
  background: var(--portal-surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--portal-ink-soft);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

.chamado-chip.is-selected {
  border-color: var(--portal-brand);
  background: rgba(255, 107, 53, 0.1);
  color: var(--portal-brand-dk);
}

.chamado-chip:active {
  transform: scale(0.98);
}

.chamado-compose {
  flex-shrink: 0;
  background: var(--portal-surface);
  border-top: 1px solid var(--border-subtle, #d8e0ea);
  padding: 8px 12px max(10px, env(safe-area-inset-bottom));
}

.chamado-compose-form {
  position: relative;
  margin: 0;
}

.chamado-compose__row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle, #d8e0ea);
  background: var(--surface-soft, #f4f7fa);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.chamado-compose__row:focus-within {
  border-color: rgba(255, 107, 53, 0.45);
  background: var(--portal-surface);
}

.chamado-compose__input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  border: none;
  border-radius: 0;
  padding: 10px 6px;
  font-size: 16px;
  line-height: 1.35;
  font-family: inherit;
  color: var(--portal-ink);
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.chamado-compose__input:focus {
  outline: none;
}

.chamado-compose__row .portal-toolbtn {
  flex-shrink: 0;
  align-self: flex-end;
}

.chamado-compose-pending {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 8px;
  max-height: 96px;
  overflow-y: auto;
}

.chamado-compose-pending.is-hidden {
  display: none !important;
}

.chamado-pending-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(100%, 220px);
  padding: 4px 6px 4px 4px;
  border-radius: 10px;
  background: var(--surface-soft, #f4f7fa);
  border: 1px solid var(--border-subtle, #d8e0ea);
}

.chamado-pending-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.chamado-pending-ico {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 107, 53, 0.12);
  color: var(--portal-brand);
  flex-shrink: 0;
  font-size: 14px;
}

.chamado-pending-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--portal-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.chamado-pending-remove {
  border: none;
  background: transparent;
  color: var(--portal-ink-soft);
  width: var(--portal-touch);
  height: var(--portal-touch);
  max-width: 32px;
  max-height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}

.chamado-anexos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chamado-anexo-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 140px;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(26, 58, 82, 0.08);
  background: rgba(255, 255, 255, 0.95);
}

.chamado-anexo-card--own {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
}

.chamado-anexo-card--own .chamado-anexo-name,
.chamado-anexo-card--own .chamado-anexo-size {
  color: rgba(255, 255, 255, 0.95);
}

.chamado-anexo-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #e2e8f0;
}

.chamado-anexo-card--doc,
.chamado-anexo-card--video {
  flex-direction: row;
  align-items: center;
  max-width: 200px;
  padding: 8px 10px;
  gap: 8px;
}

.chamado-anexo-doc-ico {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 107, 53, 0.12);
  color: var(--portal-brand);
  flex-shrink: 0;
  font-size: 16px;
}

.chamado-anexo-card--own .chamado-anexo-doc-ico {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.chamado-one-open-hint {
  margin: 0 0 8px;
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.4;
  font-weight: 500;
  color: var(--portal-ink-soft);
  opacity: 0.9;
}

.chamado-one-open-hint.is-hidden {
  display: none;
}

.chamado-anexo-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.chamado-anexo-name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--portal-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px 6px;
}

.chamado-anexo-card--doc .chamado-anexo-name {
  padding: 0;
}

.chamado-anexo-size {
  font-size: 10px;
  color: var(--portal-ink-soft);
  font-variant-numeric: tabular-nums;
}

.chamado-feedback {
  flex-shrink: 0;
  margin: 0 14px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.chamado-feedback.is-hidden {
  display: none;
}

.chamado-feedback--err {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

@media (min-width: 768px) {
  .chamado-dialog {
    max-width: 480px;
    max-height: min(92dvh, 820px);
    margin: auto;
    border-radius: var(--portal-radius-xl);
    box-shadow: var(--portal-shadow-lift);
  }

  .chamado-dialog-inner {
    max-height: min(92dvh, 820px);
    border-radius: var(--portal-radius-xl);
    overflow: hidden;
  }
}
