/* ============================================================
   Passo 365 — COMPONENTES COMPARTILHADOS
   Menu lateral, cabeçalho, botões, cartões, mural, estado vazio.
   Só consome variáveis de css/tokens.css — nenhum valor solto.
   Tela nova ou alterada reutiliza estas classes (ver CLAUDE.md).
   ============================================================ */

/* ---------------- Shell ---------------- */
.p365 { display: flex; height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg-1); color: var(--tx-1); font-size: var(--fs-14); line-height: var(--lh-base); }
.p365-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p365-content { flex: 1; min-height: 0; overflow-y: auto; background: var(--bg-0); padding: var(--sp-28) clamp(var(--sp-16), 3vw, 32px) var(--sp-40); }
.p365-content > * { max-width: var(--content-max); margin-left: auto; margin-right: auto; }
.p365-content.p365--scroll-lock { overflow: hidden; }
html.p365--scroll-lock { overflow: hidden; }
html.p365--scroll-lock.p365--scroll-gutter { scrollbar-gutter: stable; }
.p365-stack { display: flex; flex-direction: column; gap: var(--sp-20); }

/* ---------------- Menu lateral ---------------- */
.p365-side { width: var(--nav-w); flex: none; display: flex; flex-direction: column; background: var(--bg-0); border-right: 1px solid var(--line); transition: width .18s ease; }
.p365-side__brand { height: var(--h-bar); flex: none; display: flex; align-items: center; justify-content: flex-start; gap: var(--sp-10); padding: 0 var(--sp-20); border-bottom: 1px solid var(--line); overflow: hidden; }
.p365-side__name { font-size: var(--fs-17); font-weight: 500; letter-spacing: -.01em; color: var(--tx-1); white-space: nowrap; }
.p365-side__name b { font-weight: 700; }
.p365-side__mark { display: none; width: var(--h-28); height: var(--h-28); flex: none; place-items: center; border-radius: var(--r-8); background: var(--ac-solid); color: var(--ac-on); font-size: var(--fs-14); font-weight: 700; }

.p365-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-12); padding: var(--sp-10) var(--sp-10) var(--sp-16); }
.p365-nav__sec { display: flex; flex-direction: column; gap: var(--sp-2); }
.p365-nav__grp { padding: var(--sp-8) var(--sp-10) var(--sp-6); font-size: var(--fs-11); font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--tx-3); white-space: nowrap; }
.p365-nav a { display: flex; align-items: center; gap: var(--sp-10); height: var(--h-36); padding: 0 var(--sp-10); border-radius: var(--r-8); font-size: var(--fs-14); font-weight: 500; color: var(--tx-2); white-space: nowrap; overflow: hidden; text-decoration: none; transition: background var(--ease), color var(--ease); }
.p365-nav a .ic { width: var(--ic-18); height: var(--ic-18); flex: none; display: flex; color: var(--tx-3); }
.p365-nav a .ic svg { width: var(--ic-18); height: var(--ic-18); }
.p365-nav a .label { overflow: hidden; text-overflow: ellipsis; }
.p365-nav a:hover { background: var(--veil); color: var(--tx-1); }
.p365-nav a.on { background: var(--bg-3); color: var(--tx-1); font-weight: 600; }
.p365-nav a.on .ic { color: var(--ac-ink); }
.p365-nav a .soon { margin-left: auto; font-size: var(--fs-11); font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--tx-3); }

/* Recolhido: só ícones, centralizados */
.p365--nav-collapsed .p365-side { width: var(--nav-w-rail); }
.p365--nav-collapsed .p365-side__brand { justify-content: center; padding: 0; }
.p365--nav-collapsed .p365-side__name,
.p365--nav-collapsed .p365-nav__grp,
.p365--nav-collapsed .p365-nav a .label,
.p365--nav-collapsed .p365-nav a .soon { display: none; }
.p365--nav-collapsed .p365-side__mark { display: grid; }
.p365--nav-collapsed .p365-nav a { justify-content: center; padding: 0; }

/* ---------------- Cabeçalho ---------------- */
.p365-top { height: var(--h-bar); flex: none; display: flex; align-items: center; gap: var(--sp-12); padding: 0 var(--sp-16) 0 var(--sp-12); background: var(--bg-1); border-bottom: 1px solid var(--line); color: var(--tx-1); }
.p365-top__title { margin: 0; font-size: var(--fs-11); font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--tx-3); white-space: nowrap; }
.p365-top__right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-12); flex: none; }
.p365-top__sep { width: 1px; height: 22px; background: var(--line); flex: none; }
.p365-user { display: flex; align-items: center; gap: var(--sp-10); flex: none; }
.p365-user__text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.p365-user__name { font-size: var(--fs-13-5); font-weight: 600; color: var(--tx-1); white-space: nowrap; }
.p365-user__cargo { font-size: var(--fs-12); color: var(--tx-3); }

/* ---------------- Avatar ---------------- */
.p365-avatar { width: var(--h-32); height: var(--h-32); flex: none; display: grid; place-items: center; border-radius: var(--r-round); background: var(--bg-3); color: var(--tx-2); font-size: var(--fs-12); font-weight: 600; }
.p365-avatar--accent { background: var(--ac-soft); color: var(--ac-ink); }

/* ---------------- Botões ---------------- */
.p365-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-6); height: var(--h-34); padding: 0 var(--sp-12); border: 1px solid var(--line); border-radius: var(--r-9); background: var(--bg-1); color: var(--tx-1); font-size: var(--fs-13); font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none; transition: background var(--ease), color var(--ease); }
.p365-btn:hover { background: var(--bg-2); color: var(--tx-1); }
.p365-btn:disabled { opacity: .45; cursor: not-allowed; }
.p365-btn svg { flex: none; color: var(--tx-2); }
.p365-btn--primary { height: var(--h-36); padding: 0 var(--sp-14) 0 var(--sp-12); border-color: transparent; background: var(--ac-solid); color: var(--ac-on); font-size: var(--fs-13-5); font-weight: 600; }
.p365-btn--primary:hover { background: var(--ac-solid); color: var(--ac-on); filter: brightness(1.08); }
.p365-btn--primary svg { color: inherit; }
.p365-btn--sm { height: var(--h-32); padding: 0 var(--sp-12); border-radius: var(--r-8); font-size: var(--fs-13); }
.p365-btn--sm.p365-btn--primary { padding: 0 var(--sp-14); font-size: var(--fs-13); }
.p365-btn--icon { width: var(--h-32); height: var(--h-32); padding: 0; border-color: transparent; border-radius: var(--r-8); background: transparent; color: var(--tx-2); }
.p365-btn--icon:hover { background: var(--bg-2); color: var(--tx-1); }
.p365-btn--icon svg { color: inherit; }
.p365-btn--xs { width: var(--h-28); height: var(--h-28); border-radius: var(--r-7); color: var(--tx-3); }
.p365-btn--danger, .p365-btn.crm-danger { color: var(--red-ink); }
.p365-btn--danger:hover, .p365-btn.crm-danger:hover { background: var(--danger-tint); color: var(--red-ink); }
.p365-btn--danger svg { color: inherit; }
.p365-btn--link { height: var(--h-28); padding: 0 var(--sp-8); gap: var(--sp-4); border-color: transparent; border-radius: var(--r-7); background: transparent; color: var(--ac-ink); font-weight: 600; }
.p365-btn--link:hover { background: var(--ac-soft); color: var(--ac-ink); }
.p365-btn--link svg { color: inherit; }
@media (hover: none) { .p365-btn--icon, .p365-btn--xs { min-width: var(--h-36); min-height: var(--h-36); } }

/* ---------------- Título de página ---------------- */
.p365-page-head { display: flex; flex-direction: column; gap: var(--sp-6); margin-bottom: var(--sp-28); }
.p365-page-head h1 { margin: 0; font-size: var(--fs-24); font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.p365-page-head p { margin: 0; font-size: var(--fs-13-5); color: var(--tx-2); max-width: 620px; }
.p365-page-head__bar { display: none; }
.p365-page-head--acoes { flex-direction: row; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-12); margin-bottom: 0; }
.p365-page-head--acoes > div:first-child { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: var(--sp-6); }
.p365-page-head__acoes { display: flex; flex-wrap: wrap; gap: var(--sp-8); }

/* ---------------- Cartões ---------------- */
.p365-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-16); }
.p365-card { display: flex; flex-direction: column; gap: var(--sp-12); padding: var(--sp-20); background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-12); }
.p365-card h3 { margin: 0; font-size: var(--fs-17); font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-8); }
.p365-card p { margin: 0; font-size: var(--fs-13); color: var(--tx-3); line-height: var(--lh-base); }
.p365-card .val { font-size: var(--fs-24); font-weight: 600; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--tx-1); }
.p365-label, .p365-card .lbl { font-size: var(--fs-11); font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--tx-3); }
.p365-card .lbl { margin-bottom: var(--sp-10); }

/* Cartão de resumo (Dashboard) */
.dash-card { gap: var(--sp-4); min-height: var(--card-min-h); }
.dash-card__body { flex: 1; min-height: var(--sp-14); display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.dash-card__titulo { font-size: var(--fs-17); font-weight: 600; letter-spacing: -.01em; line-height: var(--lh-base); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.dash-card__quando { font-size: var(--fs-14); font-weight: 500; color: var(--tx-1); }
.dash-card__meta { font-size: var(--fs-13); color: var(--tx-3); overflow-wrap: anywhere; }
.dash-card__vazio { display: flex; flex-direction: column; gap: var(--sp-4); }
.dash-card__vazio b { font-size: var(--fs-17); font-weight: 600; letter-spacing: -.01em; color: var(--tx-1); }
.dash-card__vazio span { font-size: var(--fs-13); color: var(--tx-3); }
.dash-card__foot { display: flex; align-items: center; gap: var(--sp-12); padding-top: var(--sp-12); border-top: 1px solid var(--line); font-size: var(--fs-13); color: var(--tx-3); }
.dash-card__foot > span { flex: 1; min-width: 0; }
.dash-card__foot .p365-btn--link { flex: none; margin-right: calc(var(--sp-8) * -1); }
.dash-card__lista { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--sp-6); font-size: var(--fs-14); }
.dash-card__lista b { font-weight: 600; color: var(--tx-1); display: inline-flex; align-items: center; gap: var(--sp-6); }
.dash-card__lista span { color: var(--tx-3); font-size: var(--fs-13); }

/* Painel "Personalizar" */
.dash-cfg { display: flex; flex-direction: column; gap: var(--sp-6); max-height: 55vh; overflow-y: auto; }
.dash-cfg__item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-10); padding: var(--sp-10) var(--sp-14); border-radius: var(--r-10); background: var(--bg-2); }
.dash-cfg__item--off { opacity: .55; }
.dash-cfg__check { display: flex; align-items: center; gap: var(--sp-12); flex: 1; min-width: 0; cursor: pointer; font-size: var(--fs-13); }
.dash-cfg__check input { width: auto; margin: 0; flex: none; }
.dash-cfg__check span { display: flex; flex-direction: column; min-width: 0; gap: var(--sp-2); }
.dash-cfg__check b { font-weight: 600; }
.dash-cfg__check small { font-size: var(--fs-12); color: var(--tx-3); }
.dash-cfg__mover { display: flex; gap: var(--sp-4); flex: none; }

/* ---------------- Seção em cartão + Mural de avisos ---------------- */
.p365-section { display: flex; flex-direction: column; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-12); }
.p365-section__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-12); padding: var(--sp-20); }
.p365-section__title { display: flex; flex-direction: column; gap: var(--sp-4); flex: 1 1 220px; min-width: 0; }
.p365-section__title h2 { margin: 0; font-size: var(--fs-17); font-weight: 600; letter-spacing: -.01em; }
.p365-section__title p { margin: 0; font-size: var(--fs-13-5); color: var(--tx-2); text-wrap: pretty; }
.p365-section__body { padding: var(--sp-20); border-top: 1px solid var(--line); }
.p365-composer { display: flex; flex-direction: column; gap: var(--sp-10); padding: var(--sp-16) var(--sp-20); border-top: 1px solid var(--line); }
.p365-composer textarea { width: 100%; min-height: 84px; resize: vertical; padding: var(--sp-10) var(--sp-12); border: 0; outline: 0; border-radius: var(--r-10); background: var(--bg-2); color: var(--tx-1); font: inherit; }
.p365-composer__acoes { display: flex; justify-content: flex-end; gap: var(--sp-8); }
.p365-aviso { display: flex; gap: var(--sp-12); padding: var(--sp-14) var(--sp-20); border-top: 1px solid var(--line); }
.p365-aviso__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.p365-aviso__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-8); }
.p365-aviso__autor { font-size: var(--fs-13-5); font-weight: 600; }
.p365-aviso__quando { font-size: var(--fs-12); color: var(--tx-3); }
.p365-aviso__texto { white-space: pre-wrap; overflow-wrap: anywhere; text-wrap: pretty; }
.p365-aviso__acoes { display: flex; gap: var(--sp-4); flex: none; align-items: flex-start; }
.p365-empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); padding: var(--sp-44) var(--sp-24) var(--sp-56); border-top: 1px solid var(--line); text-align: center; }
.p365-empty b { font-size: var(--fs-14); font-weight: 600; }
.p365-empty span { font-size: var(--fs-13-5); color: var(--tx-3); }

/* ---------------- Celular e tablet ----------------
   Até 1024px o menu vira gaveta (off-canvas) aberta pelo botão do cabeçalho. */
.p365-scrim { display: none; }
@media (max-width: 1024px) {
  .p365-side { position: fixed; z-index: 700; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); height: 100vh; height: 100dvh; transform: translateX(-102%); transition: transform .22s ease; }
  .p365-side__brand { padding-top: env(safe-area-inset-top); height: auto; min-height: var(--h-bar); }
  .p365--nav-open .p365-side { transform: none; box-shadow: var(--shadow-pop); }
  .p365--nav-collapsed .p365-side { width: min(300px, 86vw); }
  .p365-scrim { display: block; position: fixed; inset: 0; z-index: 650; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
  .p365--nav-open .p365-scrim { opacity: 1; pointer-events: auto; }
  html.p365--drawer-open { overflow: hidden; }
  .p365-main { width: 100%; }
}
@media (max-width: 760px) {
  .p365-user__text, .p365-btn__txt { display: none; }
  .p365-top__title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .p365-top__right { gap: var(--sp-8); }
  .p365-page-head h1 { font-size: var(--fs-17); }
  /* iOS dá zoom ao focar campo com fonte menor que 16px. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea { font-size: var(--fs-16) !important; }
}

/* ---------------- Modais: peças compartilhadas ---------------- */
.p365-modal__sub { margin: 0 0 var(--sp-12); font-size: var(--fs-13); color: var(--tx-3); }
.p365-modal__erro { margin-bottom: var(--sp-12); padding: var(--sp-10) var(--sp-14); border-radius: var(--r-8); background: var(--danger-tint); color: var(--red-ink); font-size: var(--fs-13); font-weight: 600; }
.p365-modal--md { max-width: 540px; }
.p365-modal__actions--split { justify-content: space-between; flex-wrap: wrap; }
.p365-modal__grupo { display: flex; gap: var(--sp-8); }
.p365-form-1col { grid-template-columns: 1fr; }
.p365-check { flex-direction: row; align-items: center; gap: var(--sp-8); }
.p365-btn--danger-solid { background: var(--red-ink); color: var(--ac-on); }
.p365-btn--danger-solid:hover { background: var(--red-ink); color: var(--ac-on); }

/* ---------------- Botões dos módulos ----------------
   Os módulos têm classes próprias (.pv-btn, .sm-btn, .mat-*, .co-btn, .cad-*).
   Aqui todas ganham a mesma aparência de .p365-btn. O prefixo "body" dá
   especificidade para vencer o css/<modulo>.css, que carrega depois.
   Tela nova NÃO usa essas classes: usa .p365-btn. */
body :is(.pv-btn, .sm-btn, .mat-btn-secondary, .mat-toolbar__clear, .cad-pager button, .p365-back, .ct-col__add, .sm-add, .co-btn) {
  background: var(--bg-1); color: var(--tx-1); border: 1px solid var(--line); border-radius: var(--r-9); font-weight: 500; box-shadow: none;
}
body :is(.pv-btn, .sm-btn, .mat-btn-secondary, .mat-toolbar__clear, .cad-pager button, .p365-back, .ct-col__add, .sm-add, .co-btn):hover:not(:disabled) { background: var(--bg-2); color: var(--tx-1); }
body :is(.pv-btn--primary, .sm-btn--primary, .sm-btn--strong, .mat-btn-primary, .mat-toolbar__new, .cad-btn--criar, .co-btn--primary) {
  background: var(--ac-solid); color: var(--ac-on); border: 1px solid transparent; border-radius: var(--r-9); font-weight: 600;
}
body :is(.pv-btn--primary, .sm-btn--primary, .sm-btn--strong, .mat-btn-primary, .mat-toolbar__new, .cad-btn--criar, .co-btn--primary):hover:not(:disabled) { background: var(--ac-solid); color: var(--ac-on); filter: brightness(1.08); }
body :is(.pv-btn--ghost, .sm-btn--ghost, .sm-btn--link, .pv-btn--outline) { background: transparent; color: var(--ac-ink); border-color: transparent; }
body :is(.pv-btn--ghost, .sm-btn--ghost, .sm-btn--link, .pv-btn--outline):hover:not(:disabled) { background: var(--bg-2); color: var(--tx-1); }
body :is(.pv-btn--danger, .sm-btn--danger, .mat-btn-remove, .co-btn--danger) { background: transparent; color: var(--red-ink); border-color: transparent; border-radius: var(--r-9); }
body :is(.pv-btn--danger, .sm-btn--danger, .mat-btn-remove, .co-btn--danger):hover:not(:disabled) { background: var(--danger-tint); color: var(--red-ink); }
body :is(.sm-btn--soft, .sm-btn--ok-soft, .co-btn--danger-fill) { border-color: transparent; border-radius: var(--r-9); }
body :is(.sm-btn--soft, .sm-btn--ok-soft) { background: var(--ac-soft); color: var(--ac-ink); }
body .sm-btn--ok { background: var(--ok); color: var(--ac-on); border-color: transparent; border-radius: var(--r-9); }
