/* =============================================================
   app.css — Área logada (associado) + Painel administrativo
   Depende das variáveis de main.css
   ============================================================= */

body.app { background: var(--paper-3); }

.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
/* impede que conteúdo largo (tabelas) estoure a coluna e quebre o layout */
.shell > * { min-width: 0; }
.main { min-width: 0; overflow-x: hidden; margin-inline: auto; }

/* Tabela: sem quebra de linha, mais organizada */
table.data td, table.data th { white-space: nowrap; }
table.data td small { white-space: nowrap; }

/* ---------- Topbar com sininho (sempre visível) ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px clamp(20px,4vw,44px); background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 45; }
.topbar__title { font-size: 1rem; font-weight: 800; }
.topbar-mark { width: 34px; height: 34px; border-radius: 10px; flex: none; }
.topbar-mark svg { width: 26px; height: 26px; }
.topbar__right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.mobile-only { display: none; }
@media (max-width: 860px){ .mobile-only { display: block; } }

.bell-wrap { position: relative; }
.bell { position: relative; width: 44px; height: 44px; border-radius: 12px; background: var(--paper-3); display: grid; place-items: center; color: var(--ink-700); transition: .2s; }
.bell:hover { background: var(--teal-50); color: var(--primary-strong); }
.bell svg { width: 22px; height: 22px; }
.bell__badge { position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 100px; background: var(--coral-500); color: #fff; font-size: .66rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface); }
.notif-panel { position: absolute; top: 52px; right: 0; width: min(370px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 70; overflow: hidden; display: none; }
.notif-panel.is-open { display: block; animation: fadeUp .25s var(--ease); }
.notif-panel__head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.notif-list { max-height: 66vh; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .2s; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--paper-2); }
.notif-item .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; font-size: 1.05rem; }
.notif-item b { font-size: .9rem; display: block; line-height: 1.25; }
.notif-item small { color: var(--muted); font-size: .8rem; }
.notif-empty { padding: 34px; text-align: center; color: var(--muted); font-size: .9rem; }
.notif-clear { font-size: .76rem; font-weight: 700; color: var(--coral-500); background: none; }
.notif-clear:hover { text-decoration: underline; }
.notif-item { align-items: center; }
.notif-x { width: 26px; height: 26px; border-radius: 8px; background: transparent; color: var(--muted); flex: none; font-size: .8rem; transition: .2s; }
.notif-x:hover { background: var(--coral-500); color: #fff; }

/* ---------- Chat (associado) ---------- */
.chat { display: grid; grid-template-rows: 1fr auto; height: calc(100vh - 230px); min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.chat__msgs { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: var(--paper-2); }
.bubble { max-width: 74%; padding: 10px 14px; border-radius: 16px; font-size: .92rem; box-shadow: var(--shadow-sm); word-break: break-word; }
.bubble .meta { display: block; font-size: .66rem; margin-top: 5px; opacity: .75; }
.bubble--user { align-self: flex-end; background: var(--grad-primary); color: #fff; border-bottom-right-radius: 5px; }
.bubble--admin { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.bubble img { max-width: 240px; border-radius: 10px; margin-bottom: 4px; cursor: pointer; display: block; }
.bubble .file { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: underline; background: none; border: none; color: inherit; cursor: pointer; font-size: inherit; padding: 0; }
.chat__form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); align-items: center; }
.chat__form .input { flex: 1; }
.chat__attach { width: 44px; height: 44px; border-radius: 12px; background: var(--paper-3); display: grid; place-items: center; cursor: pointer; position: relative; flex: none; color: var(--ink-500); }
.chat__attach:hover { background: var(--teal-50); }
.chat__attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.chat-empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 40px; }
.chat__preview { padding: 8px 12px; border-top: 1px solid var(--border); background: var(--paper-2); font-size: .82rem; display: flex; align-items: center; gap: 10px; }
.chat__preview img { height: 40px; border-radius: 6px; }

/* ---------- Comunicação (admin) ---------- */
.com-layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; height: calc(100vh - 190px); min-height: 460px; }
.com-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow-y: auto; }
.com-group__title { padding: 9px 16px; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--primary-strong); background: var(--paper-3); position: sticky; top: 0; z-index: 1; }
.com-thread { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.com-thread:hover, .com-thread.is-active { background: var(--teal-50); }
.com-thread b { font-size: .9rem; display: block; }
.com-thread small { color: var(--muted); font-size: .78rem; }
.com-thread .unread { margin-left: auto; background: var(--coral-500); color: #fff; border-radius: 100px; min-width: 20px; height: 20px; display: grid; place-items: center; font-size: .66rem; font-weight: 700; flex: none; }
.com-chat { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.com-chat .chat { height: 100%; border: none; border-radius: 0; }
@media (max-width: 820px){ .com-layout { grid-template-columns: 1fr; } .com-layout .com-chat { display: none; } .com-layout.show-chat .com-list { display: none; } .com-layout.show-chat .com-chat { display: block; } }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 22px 16px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px; z-index: 40;
  overflow-y: auto;
}
.sidebar__foot { position: sticky; bottom: 0; background: var(--surface); }
.sidebar .brand { padding: 6px 8px 20px; }
.side-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  font-weight: 600; color: var(--ink-700); font-size: .94rem; transition: .2s; position: relative;
}
.side-link svg { width: 20px; height: 20px; flex: none; color: var(--ink-400); transition: .2s; }
.side-link:hover { background: var(--paper-3); }
.side-link.is-active { background: var(--teal-50); color: var(--primary-strong); }
.side-link.is-active svg { color: var(--primary); }
.side-link .count { margin-left: auto; background: var(--teal-100); color: var(--teal-700); font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 100px; }
.sidebar__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 10px 8px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--grad-primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
/* avatar com upload de foto */
.avatar--edit { cursor: pointer; }
.avatar--edit input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.avatar__cam { position: absolute; inset: auto 0 0 0; height: 40%; background: rgba(15,46,40,.55); color: #fff; font-size: .6rem; display: grid; place-items: center; opacity: 0; transition: opacity .2s; }
.avatar--edit:hover .avatar__cam { opacity: 1; }

/* Combo de busca (lançar mensalidade) */
.combo { position: relative; }
.combo__list { position: absolute; z-index: 5; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto; margin-top: 4px; display: none; }
.combo__list.is-open { display: block; }
.combo__opt { padding: 11px 14px; cursor: pointer; font-size: .9rem; border-bottom: 1px solid var(--border); }
.combo__opt:last-child { border-bottom: none; }
.combo__opt:hover, .combo__opt.is-active { background: var(--teal-50); }
.combo__opt small { color: var(--muted); display: block; }

/* Seleção de documentos para imprimir */
.docpick { display: grid; gap: 10px; margin: 8px 0 18px; }
.docpick label { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; }
.docpick label:hover { border-color: var(--teal-300); }
.docpick .thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--paper-3); }
.side-user b { font-size: .88rem; display: block; line-height: 1.2; }
.side-user span { font-size: .76rem; color: var(--muted); }

/* (Topbar definida acima, sempre visível, com sininho) */

/* ---------- Main ---------- */
.main { padding: 32px clamp(20px, 4vw, 44px); max-width: 1200px; width: 100%; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.page-head p { color: var(--text-soft); margin-top: 6px; }

.view { display: none; animation: fadeUp .4s var(--ease); }
.view.is-active { display: block; }

/* ---------- Stat cards ---------- */
.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; margin-bottom: 26px; }
@media (max-width: 960px){ .stats-row { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 520px){ .stats-row { grid-template-columns: 1fr; } }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.stat-card .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 12px; }
.stat-card b { font-size: 1.8rem; display: block; line-height: 1; }
.stat-card span { color: var(--muted); font-size: .85rem; }

/* ---------- Panel/card ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow-sm); margin-bottom: 22px; }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panel__head h3 { font-size: 1.2rem; }

/* ---------- Cards de pessoas (informações) ---------- */
#personGrid { display: block; }
.person-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); max-width: 620px; }
.person-card__head { padding: 18px 20px; display: flex; align-items: center; gap: 14px; background: var(--grad-soft); }
.person-card__head .avatar { width: 48px; height: 48px; }
.person-card__head b { display: block; }
.person-card__head small { color: var(--muted); }
.person-card__body { padding: 18px 20px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--muted); }
.info-row .v { font-weight: 600; text-align: right; }
.info-sub { margin-top: 16px; }
.info-sub__t { font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--primary-strong); margin-bottom: 4px; padding-top: 10px; border-top: 1px solid var(--border); }
.wa-btn { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; background: #25d366; color: #fff; padding: 3px 9px; border-radius: 100px; margin-left: 8px; white-space: nowrap; }
.wa-btn:hover { background: #1eb85a; }

/* ---------- Abas de pessoas (Informações) ---------- */
.person-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.ptab { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 12px 12px 0 0; font-weight: 700; font-size: .92rem; color: var(--ink-400); background: transparent; position: relative; top: 2px; border: 2px solid transparent; border-bottom: none; transition: .2s; }
.ptab:hover { color: var(--primary-strong); background: var(--paper-2); }
.ptab.is-active { color: var(--primary-strong); background: var(--surface); border-color: var(--border); border-bottom: 2px solid var(--surface); }
.ptab .ptab-av { width: 26px; height: 26px; border-radius: 50%; background: var(--grad-primary); color: #fff; display: grid; place-items: center; font-size: .72rem; overflow: hidden; flex: none; }
.ptab .ptab-av img { width: 100%; height: 100%; object-fit: cover; }
.ptab .ok-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--teal-500); color: #fff; display: grid; place-items: center; font-size: .62rem; }
.ptab .pend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber-400); }
.ptab--add { color: var(--primary-strong); background: var(--teal-50); border-radius: 100px; top: 0; align-self: center; }
.ptab--add:hover { background: var(--teal-100); }

/* ---------- Documentos ---------- */
.doc-progress { height: 8px; background: var(--paper-3); border-radius: 100px; overflow: hidden; margin: 10px 0 4px; }
.doc-progress__bar { height: 100%; background: var(--grad-primary); border-radius: 100px; transition: width .5s var(--ease); }
.doc-list { display: grid; gap: 10px; margin-top: 14px; }
.doc-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px; transition: .2s; }
.doc-item.is-sent { border-color: var(--teal-300); background: var(--teal-50); }
.doc-item .doc-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--paper-3); display: grid; place-items: center; color: var(--ink-400); flex: none; }
.doc-item.is-sent .doc-ic { background: var(--teal-100); color: var(--teal-700); }
.doc-item b { font-size: .9rem; display: block; }
.doc-item small { font-size: .76rem; color: var(--muted); }
.doc-item__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.doc-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); cursor: pointer; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.data th, table.data td { padding: 13px 16px; text-align: left; font-size: .88rem; border-bottom: 1px solid var(--border); }
table.data th { background: var(--paper-2); font-weight: 700; color: var(--ink-500); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
table.data tbody tr { transition: background .2s; }
table.data tbody tr:hover { background: var(--paper-2); }
table.data td .row-actions { display: flex; gap: 6px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--paper-3); color: var(--ink-500); transition: .2s; }
.icon-btn:hover { background: var(--primary); color: #fff; }
.icon-btn.danger:hover { background: var(--coral-500); }

/* ---------- Segmented tabs internas ---------- */
.seg { display: inline-flex; gap: 4px; background: var(--paper-3); padding: 4px; border-radius: 100px; }
.seg button { padding: 8px 16px; border-radius: 100px; font-weight: 600; font-size: .85rem; color: var(--ink-400); }
.seg button.is-active { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow-sm); }

/* ---------- Editor de post (admin) ---------- */
.blocks { display: grid; gap: 12px; margin: 14px 0; }
.block-item { border: 1.5px solid var(--border); border-radius: 12px; padding: 14px; background: var(--paper-2); position: relative; }
.block-item__bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.block-item__type { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--primary-strong); }
.block-add { display: flex; gap: 8px; flex-wrap: wrap; }
.block-add button { padding: 8px 14px; border-radius: 10px; background: var(--teal-50); color: var(--teal-700); font-weight: 600; font-size: .84rem; border: 1px solid var(--teal-100); }
.block-add button:hover { background: var(--teal-100); }
.gallery-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.gallery-preview img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* Empreendimentos no admin (agrupados) */
.assoc-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; background: var(--surface); }
.assoc-block__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.emp-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--border); margin: 4px; font-size: .85rem; }
.emp-chip button { color: var(--ink-400); }
.emp-chip button:hover { color: var(--coral-500); }

/* ---------- Responsivo: sidebar vira drawer ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; transform: translateX(-105%); transition: transform .35s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .backdrop { position: fixed; inset: 0; background: rgba(15,46,40,.4); z-index: 39; display: none; }
  .backdrop.is-open { display: block; }
}
