/* =========================================================================
   Cuidare SJC — Registros
   Design system único (sem multi-tenant), paleta azul/ciano da marca.
   ========================================================================= */

:root {
  --primary: #0EA5E9;
  --primary-dark: #0284C7;
  --secondary: #06B6D4;
  --primary-soft: rgba(14, 165, 233, 0.10);
  --accent-pink: #EC4899;

  --bg: #F5F8FA;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E5EAF0;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-soft: #94A3B8;

  --danger: #EF4444;
  --danger-soft: #FEE2E2;
  --success: #10B981;
  --success-soft: #D1FAE5;
  --warning: #F59E0B;
  --warning-soft: #FEF3C7;

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px -20px rgba(15, 23, 42, 0.25);

  --sidebar-w: 240px;
  --header-h: 60px;
  --bottom-nav-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0 0 8px; letter-spacing: -0.01em; }
.muted { color: var(--text-muted); }
.text-xs { font-size: 12.5px; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.hstack { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* A barra do topo tem altura fixa — nunca deixar o conteúdo quebrar linha ali (evita corte visual). */
.topbar-inner .hstack { flex-wrap: nowrap; }
.gap-1 { gap: 8px; }
.vstack { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar-inner {
  height: 100%; max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
}
.menu-toggle {
  display: none; background: none; border: 0; padding: 8px; margin-right: 4px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
}
.menu-toggle svg { width: 22px; height: 22px; }
.menu-toggle:hover { background: var(--surface-2); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { height: 32px; border-radius: 8px; }
.brand-name {
  font-weight: 800; font-size: 18px; letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.install-btn {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer;
}
.install-btn:hover { border-color: var(--primary); color: var(--primary); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; }
.user-chip:hover { background: var(--surface-2); }
.user-name { font-weight: 600; font-size: 13.5px; display: none; }
@media (min-width: 640px) { .user-name { display: inline; } }

.avatar {
  border-radius: 50%; object-fit: cover; display: inline-block; flex-shrink: 0;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.avatar-initials {
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; border-radius: 50%; flex-shrink: 0;
}

/* ---------- Layout: sidebar + content ---------- */
.main-wrap { flex: 1; display: flex; max-width: 1400px; margin: 0 auto; width: 100%; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; padding: 18px 12px;
  border-right: 1px solid var(--border); background: var(--surface);
  position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto;
}
.sidebar-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-soft); padding: 8px 12px 6px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 600; font-size: 14px; position: relative;
}
.sidebar nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center;
}
.sidebar-backdrop { display: none; }

.sidebar-collapse-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 10px; padding: 10px 12px;
  border: 0; border-top: 1px dashed var(--border); background: none; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
.sidebar-collapse-btn:hover { background: var(--surface-2); color: var(--text); }
.sidebar-collapse-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Sidebar recolhida (só desktop/tablet — só ícones, com tooltip via title="") */
@media (min-width: 901px) {
  html.sidebar-collapsed .sidebar { width: 68px; padding-left: 8px; padding-right: 8px; }
  html.sidebar-collapsed .sidebar .nav-label,
  html.sidebar-collapsed .sidebar .sidebar-section { display: none; }
  html.sidebar-collapsed .sidebar nav a,
  html.sidebar-collapsed .sidebar-collapse-btn { justify-content: center; padding: 10px; gap: 0; }
  html.sidebar-collapsed .nav-badge { position: absolute; top: 4px; right: 4px; margin-left: 0; }
  html.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
}

.content { flex: 1; min-width: 0; padding: 22px 20px 90px; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
    padding-top: calc(var(--header-h) + 12px);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.4); z-index: 50;
  }
  .sidebar-backdrop.open { display: block; }
  .content { padding-bottom: calc(var(--bottom-nav-h) + 24px); }
  .sidebar-collapse-btn { display: none; }
}

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .bottom-nav {
    display: block; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-h);
    background: var(--surface); border-top: 1px solid var(--border); z-index: 45;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav-inner { height: 64px; display: flex; align-items: stretch; }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--text-soft); font-size: 10.5px; font-weight: 600; position: relative;
  }
  .bottom-nav a svg { width: 21px; height: 21px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .nav-badge { position: absolute; top: 4px; right: 22%; }
}

/* ---------- Flash / alerts ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; }
.flash-success { background: var(--success-soft); color: #065F46; }
.flash-error   { background: var(--danger-soft);  color: #991B1B; }
.flash-info    { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: all .15s; line-height: 1.2;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-link-mini { background: none; border: 0; color: var(--primary); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 2px 4px; }

/* ---------- Cards / panels ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; font-size: 16px; }

.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 800; }
.page-header p { margin: 2px 0 0; color: var(--text-muted); font-size: 14px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; scroll-margin-top: calc(var(--header-h) + 12px); }
.field label, label.field-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14.5px; background: var(--surface-2); font-family: inherit; transition: border-color .15s, background .15s;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.input:read-only, .input:disabled { background: var(--surface); color: var(--text-soft); cursor: default; }
.input:read-only:focus { box-shadow: none; border-color: var(--border); }
textarea.input { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .form-row-3 { grid-template-columns: 1fr; } }
.radio-group, .check-group { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.radio-group label, .check-group label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
fieldset.section { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 18px; }
fieldset.section legend { padding: 0 8px; font-weight: 700; font-size: 14px; color: var(--primary-dark); }

.checkbox-list { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
.checkbox-list-search { margin-bottom: 8px; }
.checkbox-list-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.checkbox-list-count { margin-left: auto; font-size: 12px; color: var(--text-soft); }
.checkbox-list-items { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.checkbox-list-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.checkbox-list-item:hover { background: var(--surface-2); }
.checkbox-list-item-info { display: flex; flex-direction: column; }
.checkbox-list-item-name { font-size: 13.5px; font-weight: 500; }
.checkbox-list-item-meta { font-size: 11.5px; color: var(--text-soft); }
.checkbox-list-empty { color: var(--text-soft); font-size: 13px; padding: 8px; }

/* ---------- Tables ---------- */
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.th-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--primary); text-decoration: underline; }
table.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- Badges / pills / tags ---------- */
.pill { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 600; line-height: 1.4; }
.pill-primary { background: var(--primary-soft); color: var(--primary-dark); }
.pill-success { background: var(--success-soft); color: #065F46; }
.pill-danger  { background: var(--danger-soft);  color: #991B1B; }
.pill-warning { background: var(--warning-soft); color: #92400E; }
.pill-muted   { background: var(--surface-2); color: var(--text-muted); }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 600; color: #fff; }

/* ---------- Feed (registros estilo rede social) ---------- */
.feed { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 900px) { .feed { padding-bottom: 84px; } }

.composer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 4px; max-width: 640px; margin-left: auto; margin-right: auto; scroll-margin-top: calc(var(--header-h) + 12px); }
.composer textarea { width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm); resize: vertical; font-family: inherit; font-size: 15px; line-height: 1.5; min-height: 72px; max-height: 320px; background: var(--surface-2); padding: 10px 13px; transition: border-color .15s, background .15s; }
.composer textarea:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
@media (max-width: 480px) { .composer textarea { font-size: 16px; } }
.composer-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 10px; flex-wrap: wrap; }
.composer-photo-btns { display: flex; gap: 8px; }

/* Caixa "também publicar para o outro morador da casa" — trocada de um checkbox simples
   (fácil de passar batido) pra um cartão grande e clicável inteiro, com ícone e explicação
   curta, porque cuidadoras com menos intimidade com celular relataram não perceber a opção. */
.mate-toggle {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 8px; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  cursor: pointer; transition: border-color .15s, background .15s; font-weight: normal;
}
.mate-toggle:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.mate-toggle input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--primary); }
.mate-toggle-icon { font-size: 20px; line-height: 1.2; }
.mate-toggle-text { display: flex; flex-direction: column; gap: 2px; }
.mate-toggle-text strong { font-size: 14.5px; color: var(--text); }
.mate-toggle-text small { font-size: 12.5px; color: var(--text-muted); line-height: 1.35; }
.file-preview { position: relative; margin: 10px 0; display: none; }
.file-preview.hidden { display: none !important; }
.file-preview:not(.hidden) { display: block; }
.file-preview img { max-height: 220px; border-radius: var(--radius-sm); display: block; }
.file-preview .remove {
  position: absolute; top: 8px; right: 8px; background: rgba(15,23,42,0.7); color: #fff; border: 0;
  border-radius: 50%; width: 26px; height: 26px; cursor: pointer; font-size: 15px; line-height: 1;
}

.post {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm); width: 100%; max-width: 640px; margin: 0 auto;
}
.post-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.post-header .names { flex: 1; min-width: 0; }
.post-header .author { font-weight: 700; font-size: 14.5px; }
.post-header .meta { font-size: 12.5px; color: var(--text-soft); }
.post-header .meta .edited-badge { margin-left: 4px; font-style: italic; }
.assisted-tag { font-weight: 600; color: var(--primary-dark); }
.post-actions-inline { display: flex; gap: 4px; }
.icon-action { background: none; border: 0; padding: 6px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-soft); }
.icon-action:hover { background: var(--surface-2); color: var(--text); }
/* Caixa padronizada: toda foto do feed ocupa a mesma altura, recortada ao
   centro, independente da orientação/proporção original da foto (a foto
   original completa aparece ao clicar, na lightbox). */
.post-image { width: 100%; display: block; height: 320px; object-fit: cover; cursor: zoom-in; background: var(--surface-2); }
@media (max-width: 480px) { .post-image { height: 240px; } }
.post-body { padding: 2px 16px 12px; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.post-actions { display: flex; align-items: center; gap: 4px; padding: 4px 10px 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.post-action {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: none; border: 0; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text-muted);
}
.post-action:hover { background: var(--surface-2); }
.post-action svg { width: 18px; height: 18px; }
.post-action.liked { color: var(--accent-pink); }
.post-action.liked svg { fill: var(--accent-pink); stroke: var(--accent-pink); }
.comments { display: none; padding: 6px 16px 14px; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); }
.comments.open { display: flex; }
.comments-list { display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 8px; }
.comment .bubble { background: var(--surface-2); border-radius: 14px; padding: 8px 12px; flex: 1; }
.comment-bubble-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.comment .author { font-weight: 700; font-size: 13px; }
.comment .text { font-size: 13.5px; }
.comment .meta { font-size: 11.5px; color: var(--text-soft); margin-top: 2px; }
.comment-delete-btn { background: none; border: 0; color: var(--text-soft); cursor: pointer; padding: 2px; }
.comment-delete-btn:hover { color: var(--danger); }
.comment-form { display: flex; gap: 8px; margin-top: 4px; }
.comment-form textarea { flex: 1; min-height: 38px; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 999px; font-family: inherit; font-size: 13.5px; resize: none; background: var(--surface-2); }
.comment-form textarea:focus { outline: none; border-color: var(--primary); background: #fff; }

#load-more { display: block; margin: 4px auto 0; }

.pinned-banners-wrap { max-width: 640px; margin: 0 auto 14px; display: flex; flex-direction: column; gap: 8px; }
.pinned-banner {
  display: block; background: var(--warning-soft); border: 1px solid #FDE68A; border-radius: var(--radius);
  padding: 10px 14px; font-size: 13.5px; color: #92400E;
}
.pinned-banner:hover { border-color: var(--warning); }
.pinned-banner .muted { color: #92400Eaa; }

.fab-new-post {
  position: fixed; right: 20px; bottom: calc(var(--bottom-nav-h, 0px) + 20px); width: 56px; height: 56px;
  border-radius: 50%; background: var(--primary); color: #fff; border: 0; font-size: 30px; line-height: 1;
  box-shadow: 0 10px 24px -6px rgba(14,165,233,0.5); cursor: pointer; z-index: 40; display: none;
}
@media (max-width: 900px) { .fab-new-post { display: block; } }

/* Feed: em telas pequenas remove o título grande pra parecer mais um app social
   (a barra inferior já indica que estamos no Feed). */
@media (max-width: 900px) {
  .feed-header h1, .feed-header > div > p { display: none; }
  .feed-header { margin-bottom: 10px; }
}

/* ---------- Modals (usadas por openModal()/closeModal() em app.js) ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5); align-items: center;
  justify-content: center; padding: 16px; z-index: 200;
}
.modal-backdrop.open { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-box.modal-wide { max-width: 820px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--text-soft); line-height: 1; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.flash-wrap { position: fixed; top: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.flash-wrap .flash { box-shadow: var(--shadow); animation: flashIn .18s ease; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.btn-spinner {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; animation: spin .6s linear infinite; vertical-align: -2px;
}
.btn-secondary .btn-spinner, .btn-ghost .btn-spinner { border-color: rgba(15,23,42,0.2); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Push notification nudge ---------- */
#push-nudge {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--bottom-nav-h, 0px) + 16px); max-width: 420px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 150; opacity: 0; transform: translateY(12px); transition: all .25s ease;
}
#push-nudge.show { opacity: 1; transform: translateY(0); }
.push-nudge-inner { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.push-nudge-ico { font-size: 22px; }
.push-nudge-text { flex: 1; display: flex; flex-direction: column; font-size: 12.5px; }
.push-nudge-text strong { font-size: 13.5px; }
.push-nudge-actions { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Lightbox ---------- */
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 300; align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox-img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: 18px; right: 22px; background: none; border: 0; color: #fff; font-size: 32px; cursor: pointer; }

/* ---------- Terms gate (assinatura obrigatória do cuidador) ---------- */
.terms-gate-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.65); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.terms-gate-card { background: #fff; max-width: 520px; width: 100%; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.terms-gate-head { padding: 24px 28px 16px; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; }
.terms-gate-head h2 { margin: 0 0 4px; font-size: 19px; }
.terms-gate-head p { margin: 0; font-size: 13.5px; opacity: .92; }
.terms-gate-body { padding: 20px 28px; font-size: 14px; color: #374151; }
.terms-gate-body ul { padding-left: 20px; margin: 8px 0; }
.terms-gate-note { font-size: 12.5px; color: var(--text-soft); margin-top: 12px; }
.terms-gate-actions { padding: 16px 28px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Signature terms page ---------- */
.legal-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; max-height: 320px; overflow-y: auto; font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; color: #374151; }
/* Na tela de assinatura obrigatória, uma caixa de rolagem interna dentro da página
   prende o gesto de arrastar no celular (o dedo rola só o texto, nunca sai dali pra
   alcançar o botão "Assinar" mais abaixo) — quem denunciou isso ficava, na prática,
   sem conseguir avançar. Aqui o texto flui junto com a página, com um único scroll. */
.legal-doc-signing { max-height: none; overflow: visible; }
.signature-pad-wrap { border: 1.5px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); position: relative; }
.signature-pad-wrap canvas { display: block; width: 100%; height: 180px; touch-action: none; cursor: crosshair; }
.signature-pad-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-soft); font-size: 13px; pointer-events: none; }
.signature-pad-wrap.has-signature .signature-pad-hint { display: none; }
.agreement-steps { display: flex; gap: 8px; margin-bottom: 18px; }
.agreement-step { flex: 1; height: 6px; border-radius: 999px; background: var(--border); }
.agreement-step.done { background: var(--success); }
.agreement-step.current { background: var(--primary); }

/* ---------- Auth pages (login) ---------- */
body.auth-page {
  min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center;
  padding: 30px 20px; background: linear-gradient(180deg, #F0F9FF 0%, #fff 55%); position: relative; overflow-x: hidden;
}
body.auth-page::before, body.auth-page::after { content: ''; position: fixed; border-radius: 50%; filter: blur(80px); pointer-events: none; z-index: 0; }
body.auth-page::before { width: 380px; height: 380px; background: var(--primary); top: -100px; left: -100px; opacity: .14; }
body.auth-page::after  { width: 320px; height: 320px; background: var(--secondary); bottom: -80px; right: -80px; opacity: .12; }
.auth-shell { width: 100%; max-width: 420px; position: relative; z-index: 1; }
.auth-brand-top { text-align: center; margin-bottom: 22px; }
.auth-brand-top a { font-weight: 800; font-size: 21px; letter-spacing: -.02em; color: var(--text); }
.auth-brand-top a span.dot { color: var(--primary); }
.auth-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 34px 30px 26px; }
.auth-logo-wrap { text-align: center; margin-bottom: 20px; }
.auth-icon-default {
  display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px;
  border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 8px 20px -8px var(--primary);
}
.auth-logo-img {
  display: inline-block; width: 56px; height: 56px; object-fit: contain;
  border-radius: 16px;
}
.auth-card h1 { font-size: 21px; font-weight: 800; text-align: center; margin: 0 0 6px; }
.auth-card .subtitle { text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }
.auth-msg { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13.5px; margin-bottom: 16px; }
.auth-msg.error { background: var(--danger-soft); color: #991B1B; }
.auth-msg.info  { background: var(--primary-soft); color: var(--primary-dark); }
.auth-btn { display: block; width: 100%; padding: 12px 20px; border: 0; border-radius: var(--radius-sm); font-size: 15px; font-weight: 700; cursor: pointer; text-align: center; }
.auth-btn-primary { background: var(--primary); color: #fff; margin-top: 6px; }
.auth-btn-primary:hover { background: var(--primary-dark); }
.auth-btn-secondary { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.auth-footer-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--surface-2); text-align: center; font-size: 13px; }
.auth-bottom-links { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text-soft); }
.auth-bottom-links a { color: var(--text-soft); }
.auth-bottom-links .sep { margin: 0 8px; }

/* ---------- Stat tiles (dashboard) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-tile .num { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.stat-tile .label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-soft); }
.empty-state svg { width: 44px; height: 44px; margin-bottom: 10px; opacity: .5; }

/* ---------- Ficha de avaliação ---------- */
.intake-meta { font-size: 12.5px; color: var(--text-soft); margin-bottom: 18px; padding: 8px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.med-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
@media (max-width: 640px) { .med-row { grid-template-columns: 1fr; } }

/* ---------- Plano de cuidados: horários clicáveis ---------- */
.care-slots { display: flex; flex-wrap: wrap; gap: 10px; }
.care-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 92px; height: 76px; border-radius: var(--radius-sm); border: 1.5px dashed var(--border);
  background: var(--surface-2); cursor: pointer; font-family: inherit; padding: 6px;
}
.care-slot:disabled { cursor: default; opacity: .7; }
.care-slot-empty:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.care-slot-pending { opacity: .65; cursor: default; }
.care-slot-pending .care-slot-label { color: var(--text-soft); }
.care-slot-icon { font-size: 16px; line-height: 1; }
.care-slot-time { font-weight: 700; font-size: 13px; }
.care-slot-label { font-size: 10.5px; color: var(--text-muted); }
.care-slot.slot-done { border-style: solid; border-color: var(--success); background: var(--success-soft); }
.care-slot.slot-done .care-slot-label { color: #065F46; }
.care-slot.slot-refused { border-style: solid; border-color: var(--danger); background: var(--danger-soft); }
.care-slot.slot-refused .care-slot-label { color: #991B1B; }
.care-slot.slot-delayed { border-style: solid; border-color: var(--warning); background: var(--warning-soft); }
.care-slot.slot-delayed .care-slot-label { color: #92400E; }

/* ---------- Plano de cuidados: visão "por horário" (cronológica, cruza categorias) ---------- */
.care-time-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.care-time-row:first-child { border-top: none; }
.care-time-badge { font-weight: 700; font-size: 13.5px; min-width: 44px; flex-shrink: 0; }
.care-time-cat-icon { font-size: 17px; flex-shrink: 0; }
.care-time-info { flex: 1; min-width: 0; }
.care-time-info strong { font-size: 14px; }
/* Mesmo botão .care-slot da visão por categoria, só na horizontal pra caber numa linha
   — o horário já aparece em .care-time-badge, então o rótulo de tempo some aqui dentro. */
.care-slot-row { flex-direction: row; width: auto; height: auto; padding: 7px 12px; border-radius: 999px; gap: 6px; flex-shrink: 0; }
.care-slot-row .care-slot-time { display: none; }
.care-period-tab-btn { white-space: nowrap; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status-btn {
  padding: 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface);
  font-weight: 600; font-size: 14px; cursor: pointer; font-family: inherit; text-align: left;
}
.status-btn:hover { border-color: var(--primary); }
.status-btn.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Agenda: grade semanal ---------- */
.week-grid { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.week-day-col { flex: 0 0 140px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.week-day-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); text-align: center; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.week-day-empty { text-align: center; color: var(--text-soft); font-size: 12px; padding: 10px 0; }
.week-shift-chip { background: var(--surface-2); border-left: 3px solid var(--primary); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; }
.week-shift-chip:last-child { margin-bottom: 0; }
.week-shift-time { font-size: 12px; font-weight: 700; }
.week-shift-name { font-size: 11.5px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-shift-exc { font-size: 10.5px; color: var(--warning); margin-top: 2px; }
/* Dois chips no mesmo horário marcados como "alternam" (ex.: duas cuidadoras se
   revezando semana sim, semana não) — sem isso parecia erro de cadastro duplicado. */
.week-shift-chip-alt { background: rgba(6, 182, 212, 0.08); box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.35); }
.week-shift-chip-alt .week-shift-name { white-space: normal; overflow: visible; text-overflow: clip; }
.week-shift-alt-badge { font-size: 10.5px; color: var(--secondary); font-weight: 600; margin-top: 2px; }

.weekday-checks { display: flex; gap: 6px; flex-wrap: wrap; }
.weekday-check { display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.weekday-check input { width: 18px; height: 18px; }
.weekday-check span { font-size: 11px; color: var(--text-muted); font-weight: 600; }

/* ---------- Utility ---------- */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.scroll-x { overflow-x: auto; }

/* ---------- Impressão de relatórios ---------- */
.print-letterhead, .print-only-title { display: none; }

@media print {
  .topbar, .sidebar, .sidebar-backdrop, .bottom-nav, .btn, .page-header form, .no-print { display: none !important; }
  .main-wrap { display: block !important; }
  .content { padding: 0 !important; }
  body { background: #fff !important; }
  /* <details> fechado some o conteúdo por padrão do navegador — força aberto na impressão
     (ex: "Ver texto assinado" nos termos, senão o texto completo não sai no PDF/impresso). */
  details:not([open]) > :not(summary) { display: block !important; }
  details summary { list-style: none; font-weight: 700; }
  details summary::-webkit-details-marker, details summary::marker { display: none; }

  /* Contrato/termo assinado (caregiver_agreement_view.php): formatado como documento
     formal, um por página, com cabeçalho da empresa — não como card de dashboard. */
  .print-letterhead {
    display: block; text-align: center; margin: 0 0 22px; padding-bottom: 14px;
    border-bottom: 2px solid #111;
  }
  .print-letterhead h2 { margin: 0 0 4px; font-family: Georgia, 'Times New Roman', serif; font-size: 16px; letter-spacing: .02em; }
  .print-letterhead p { margin: 0; font-size: 10.5px; color: #444; }

  .agreement-doc {
    border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    padding: 0 !important; margin: 0 0 24px !important;
    page-break-after: always; break-after: page;
  }
  .agreement-doc:last-of-type { page-break-after: auto; break-after: auto; }

  .print-only-title {
    display: block; text-align: center; font-family: Georgia, 'Times New Roman', serif;
    font-size: 15px; text-transform: uppercase; letter-spacing: .03em; margin: 0 0 18px;
  }

  .agreement-doc .legal-doc {
    max-height: none !important; overflow: visible !important; border: 0 !important;
    background: #fff !important; padding: 0 0 16px !important;
    font-family: Georgia, 'Times New Roman', serif; font-size: 12px; color: #111;
  }
  .agreement-doc .pill { border: 1px solid #999 !important; background: #fff !important; color: #111 !important; }
  .agreement-signature { max-width: 220px !important; }
}
