/* Curatela — estilos. Mobile-first, calmo, alto contraste. Light + dark. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #dbe1e7;
  --text: #1c2530;
  --text-soft: #5c6b7a;
  --primary: #0f766e;      /* teal — cuidado, confiança */
  --primary-strong: #0b5a54;
  --primary-soft: #d7efec;
  --danger: #b42318;
  --danger-soft: #fbe9e7;
  --success: #167a3c;
  --warn: #b7791f;
  --curatelado: #0f766e;
  --informal: #7c5cbf;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  --nav-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151b; --surface: #19212a; --surface-2: #222c37;
    --border: #2c3745; --text: #e7edf3; --text-soft: #9fb0c0;
    --primary: #2dd4bf; --primary-strong: #14b8a6; --primary-soft: #123632;
    --danger: #f87171; --danger-soft: #37201f; --success: #4ade80; --warn: #fbbf24;
    --curatelado: #2dd4bf; --informal: #b79ce8;
    --shadow: 0 1px 3px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; line-height: 1.45;
}
h1, h2, h3 { margin: 0 0 .3em; line-height: 1.2; }
a { color: var(--primary); }
button { font-family: inherit; }

/* ---------- Login ---------- */
.tela-login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-strong) 100%);
}
.card-login {
  background: var(--surface); width: 100%; max-width: 380px; border-radius: 20px;
  padding: 32px 26px; box-shadow: var(--shadow-lg);
}
.marca { text-align: center; margin-bottom: 22px; }
.marca-icone {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 12px;
  background: var(--primary-soft); color: var(--primary); display: grid; place-items: center;
  font-size: 30px;
}
.marca h1 { font-size: 1.5rem; }
.marca-sub { color: var(--text-soft); margin: 0; font-size: .9rem; }

form label { display: block; margin-bottom: 14px; font-size: .85rem; font-weight: 600; color: var(--text-soft); }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 12px 13px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface);
  color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
textarea { resize: vertical; min-height: 74px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 16px; font-size: 15px; font-weight: 600; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: filter .15s, background .15s; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primario { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primario:hover { filter: brightness(1.06); }
.btn-perigo { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-bloco { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.erro { color: var(--danger); background: var(--danger-soft); padding: 9px 12px; border-radius: 9px; font-size: .85rem; margin: 6px 0 0; }

/* ---------- App shell ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--border); padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px;
}
.app-header h2 { font-size: 1.15rem; margin: 0; flex: 1; }
.app-header .btn-voltar {
  background: none; border: none; color: var(--primary); font-size: 15px; font-weight: 600;
  padding: 4px 6px 4px 0; cursor: pointer; display: none;
}
.app-header.tem-voltar .btn-voltar { display: inline; }
.icon-btn {
  background: var(--surface-2); border: none; width: 38px; height: 38px; border-radius: 11px;
  font-size: 18px; cursor: pointer; color: var(--text); display: grid; place-items: center;
}

main#app {
  padding: 16px; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px);
  max-width: 780px; margin: 0 auto;
}

/* bottom nav */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface);
  border-top: 1px solid var(--border); display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-soft); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabbar a .ic { font-size: 21px; line-height: 1; }
.tabbar a.ativo { color: var(--primary); }

/* ---------- Componentes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.card-clicavel { cursor: pointer; transition: border-color .15s; }
.card-clicavel:active { border-color: var(--primary); }

.grid-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat .num { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.stat .rot { font-size: .8rem; color: var(--text-soft); }

.secao-titulo { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); font-weight: 700; margin: 20px 4px 8px; }

.linha { display: flex; align-items: center; gap: 10px; }
.entre { justify-content: space-between; }
.crescer { flex: 1; min-width: 0; }
.truncar { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.tag-curatelado { background: var(--primary-soft); color: var(--primary-strong); }
.tag-informal { background: color-mix(in srgb, var(--informal) 18%, transparent); color: var(--informal); }

.avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }

.valor-pos { color: var(--success); font-weight: 700; }
.valor-neg { color: var(--danger); font-weight: 700; }
.muted { color: var(--text-soft); }
.pequeno { font-size: .82rem; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  width: 56px; height: 56px; border-radius: 18px; background: var(--primary); color: #fff;
  border: none; font-size: 28px; box-shadow: var(--shadow-lg); cursor: pointer; z-index: 15;
  display: grid; place-items: center;
}

/* filtros / segmented */
.segment { display: flex; background: var(--surface-2); border-radius: 11px; padding: 3px; margin-bottom: 14px; }
.segment button {
  flex: 1; border: none; background: none; padding: 8px; border-radius: 9px; font-weight: 600;
  color: var(--text-soft); cursor: pointer; font-size: 14px;
}
.segment button.ativo { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* tabs no detalhe */
.tabs-detalhe { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs-detalhe button {
  border: none; background: none; padding: 10px 12px; font-weight: 600; color: var(--text-soft);
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14px;
}
.tabs-detalhe button.ativo { color: var(--primary); border-bottom-color: var(--primary); }

.campo-linha { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.campo-linha:last-child { border-bottom: none; }
.campo-linha .rot { color: var(--text-soft); font-size: .85rem; flex: none; }
.campo-linha .val { text-align: right; }

.vazio { text-align: center; color: var(--text-soft); padding: 40px 20px; }
.vazio .em { font-size: 40px; display: block; margin-bottom: 8px; }

/* miniaturas de anexos */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb {
  width: 74px; height: 74px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
  position: relative; background: var(--surface-2); display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .doc { font-size: 26px; }
.thumb .rm { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: none; width: 20px; height: 20px; border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1; }
.thumb .cat { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 9px; text-align: center; padding: 1px; }

/* modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(10,15,20,.55); z-index: 50; display: flex;
  align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px; padding-bottom: max(20px, env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
}
@media (min-width: 640px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 20px; }
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}
.modal h3 { font-size: 1.2rem; margin-bottom: 14px; }
.modal-acoes { display: flex; gap: 10px; margin-top: 18px; }
.modal-acoes .btn { flex: 1; }
.dois-campos { display: flex; gap: 10px; }
.dois-campos > * { flex: 1; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); z-index: 100;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 11px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); max-width: 90%;
}
.spinner { text-align: center; padding: 40px; color: var(--text-soft); }

.lista-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.lista-item:last-child { border-bottom: none; }
.badge-data { font-size: .78rem; color: var(--text-soft); }
.ic-tipo { width: 38px; height: 38px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 18px; flex: none; }
