/* Painel Árvore Genealógica — mobile-first */
:root {
  --forest: #1B3A2D;
  --forest-mid: #2D5A44;
  --sage: #7CB899;
  --cream: #F5EDD7;
  --bg: #f1f5f4;
  --card: #fff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --tap: 48px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}
body.painel-app { display: flex; min-height: 100vh; min-height: 100dvh; }

/* Login */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #142e23, var(--forest) 50%, #2d5a44);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 1.35rem; font-weight: 700; color: var(--forest); margin-bottom: 6px; }
.login-card .sub { font-size: .88rem; color: var(--muted); margin-bottom: 24px; }
.login-card .err {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: 10px 14px; border-radius: 10px; font-size: .85rem; margin-bottom: 16px;
}

/* Forms */
.field-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
  margin-top: 16px;
}
.field-label:first-child { margin-top: 0; }
.field-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="date"], input[type="number"], input[type="password"],
select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(124,184,153,.25);
}
textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; gap: 12px; }
@media (min-width: 600px) {
  .form-row-2 { grid-template-columns: 1fr 1fr; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 20px;
  border-radius: 12px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--forest-mid); }
.btn-secondary { background: #fff; color: var(--forest); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8fafc; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: .82rem; }
.btn-del { background: #fff; color: #b91c1c; border: 1px solid #fecaca; }
.btn-del:hover { background: #fef2f2; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Cards / list */
.search-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
@media (min-width: 600px) {
  .search-bar { flex-direction: row; }
  .search-bar input { flex: 1; }
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
}
.chip.active, .chip:hover { background: var(--forest); color: #fff; border-color: var(--forest); }

.person-list { display: flex; flex-direction: column; gap: 12px; }
.person-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 2px 12px rgba(15,23,42,.04);
}
.person-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.person-name { font-size: 1.05rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.person-meta { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.person-age {
  display: inline-block;
  background: rgba(27,58,45,.08);
  color: var(--forest);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.person-links { font-size: .8rem; color: var(--muted); margin-top: 8px; line-height: 1.45; }
.person-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Form sections */
.form-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}
.form-section h2 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--forest);
  margin-bottom: 4px;
}
.form-section .section-desc { font-size: .82rem; color: var(--muted); margin-bottom: 16px; }

.picker-box {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: #fafafa;
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .88rem;
}
.picker-item:hover { background: #fff; }
.picker-item input { width: 18px; height: 18px; accent-color: var(--forest); }
.picker-search { margin-bottom: 10px; }

/* Alerts */
.alert, .warn, .empty {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: .88rem;
  margin-bottom: 16px;
}
.alert { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.warn { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.warn code { background: rgba(0,0,0,.06); padding: 2px 6px; border-radius: 4px; font-size: .8rem; }
.empty { background: #fff; border: 1px dashed var(--border); color: var(--muted); text-align: center; padding: 40px 20px; }

.stats-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.stat-pill {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: .85rem;
}
.stat-pill strong { display: block; font-size: 1.4rem; color: var(--forest); }

.photo-field {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
}
.photo-preview {
  width: 96px; height: 96px; border-radius: 50%;
  background: rgba(27,58,45,.08); border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  flex-shrink: 0;
}
.photo-preview-img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview-placeholder { font-size: .75rem; color: var(--muted); text-align: center; padding: 8px; }
.photo-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.photo-upload-btn { cursor: pointer; }
.photo-remove { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }

.person-card-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; flex: 1; }
.person-thumb {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 2px solid rgba(27,58,45,.12);
}
.person-thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--forest), var(--forest-mid));
  color: #fff; font-weight: 700; font-size: 1rem;
}
