/* Design tokens */
:root {
  --c-primary:       #163766;
  --c-primary-light: #eef2ff;
  --c-text:          #163766;
  --c-text-2:        #787474;
  --c-text-3:        #b4b4b4;
  --c-bg:            #f4f6f9;
  --c-surface:       #ffffff;
  --c-border:        #e5e7eb;
  --shadow:          0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.11);
  --radius:          14px;
  --radius-sm:       9px;
}

/* Base */
body {
  background-color: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
}

/* Page wrapper */
.app-page {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 1rem 5rem;
}

/* Top bar */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
  max-width: 540px;
  margin: 0 auto;
}
.app-topbar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c-surface);
  border: none;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-primary);
  text-decoration: none;
  cursor: pointer;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.app-topbar-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-primary);
  text-decoration: none;
}

/* Page header */
.app-page-header {
  padding: 1.25rem 0 1.5rem;
}
.app-page-header .subtitle {
  font-size: 0.85rem;
  color: var(--c-text-2);
  margin-bottom: 2px;
  font-weight: 500;
}
.app-page-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--c-primary);
  margin: 0;
  line-height: 1.15;
}

/* Section label */
.app-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.65rem;
  margin-top: 1.75rem;
}

/* Card */
.app-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* Nav item — panel list */
.app-nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--c-text);
  transition: box-shadow 0.15s, transform 0.1s;
  margin-bottom: 0.65rem;
}
.app-nav-item:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
  color: var(--c-text);
}
.app-nav-item:hover { color: var(--c-text); }
.app-nav-item .icon-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--c-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.15rem;
  color: var(--c-primary);
}
.app-nav-item .nav-label {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
}
.app-nav-item .nav-arrow {
  color: var(--c-text-3);
  font-size: 1rem;
}

/* List item — tutors, users */
.app-list-item {
  display: block;
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--c-text);
  margin-bottom: 0.65rem;
  transition: box-shadow 0.15s;
}
.app-list-item:hover  { color: var(--c-text); box-shadow: var(--shadow-md); }
.app-list-item:active { transform: scale(0.99); }
.app-list-item .item-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-primary);
  margin-bottom: 3px;
}
.app-list-item .item-sub {
  font-size: 0.82rem;
  color: var(--c-text-2);
  margin: 0;
  line-height: 1.4;
}

/* Vertical gap utility */
.app-stack   > * + * { margin-top: 0.65rem; }
.app-stack-lg > * + * { margin-top: 1.1rem; }

/* Stat card */
.app-stat-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.app-stat-value {
  font-size: 2.75rem;
  font-weight: 700;
  color: var(--c-primary);
  line-height: 1;
}
.app-stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

/* Icon circle */
.icon-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--c-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.3rem;
  color: var(--c-primary);
}

/* Filter tabs */
.app-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.app-tab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-2);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: all 0.15s;
}
.app-tab.active,
.app-tab:hover {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

/* Search bar */
.app-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}
.app-search .app-input { flex: 1; }
.app-search-btn {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--c-primary);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* Form fields */
.app-form-group {
  margin-bottom: 1rem;
}
.app-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--c-text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}
.app-input,
.app-input.form-control {
  display: block;
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.app-input:focus,
.app-input.form-control:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(22,55,102,0.1);
}
textarea.app-input { resize: vertical; min-height: 90px; }
.password-field {
  position: relative;
}
.password-field .app-input {
  padding-right: 3rem;
}
.password-toggle {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--c-text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
}
.password-toggle:hover,
.password-toggle:focus {
  color: var(--c-primary);
  background: var(--c-primary-light);
  outline: none;
}

/* Buttons */
.btn-primary-app {
  display: block;
  width: 100%;
  padding: 0.85rem;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary-app:hover  { opacity: 0.9; color: #fff; }
.btn-primary-app:active { opacity: 0.85; }

.btn-outline-app {
  display: block;
  width: 100%;
  padding: 0.85rem;
  background: transparent;
  color: var(--c-primary);
  border: 1.5px solid var(--c-primary);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-outline-app:hover { background: var(--c-primary); color: #fff; }

.btn-danger-app {
  display: block;
  width: 100%;
  padding: 0.7rem;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger-app:hover { opacity: 0.85; }

.btn-icon-app {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--c-primary-light);
  border: none;
  color: var(--c-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-icon-app:hover  { background: #dde6f9; color: var(--c-primary); }
.btn-icon-app.danger { background: #fee2e2; color: #dc2626; }
.btn-icon-app.disabled { opacity: 0.35; pointer-events: none; }

/* Tags / badges */
.app-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
}
.app-tag-blue   { background: var(--c-primary-light); color: var(--c-primary); }
.app-tag-green  { background: #dcfce7; color: #16a34a; }
.app-tag-yellow { background: #fef9c3; color: #b45309; }
.app-tag-red    { background: #fee2e2; color: #dc2626; }
.app-tag-gray   { background: #f1f5f9; color: #64748b; }

/* Note card */
.app-note-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  border: 1.5px solid var(--c-border);
  border-left: 4px solid var(--c-primary);
  margin-bottom: 0.65rem;
}
.app-note-card p     { font-size: 0.92rem; margin-bottom: 0.5rem; }
.app-note-card small { font-size: 0.78rem; color: var(--c-text-2); }
.app-note-card.note-source-mesa {
  border-left-color: var(--c-primary);
}
.app-note-card.note-source-acolhimento {
  border-left-color: #16a34a;
}
.app-note-card.note-source-danger {
  border-left-color: #dc2626;
}
.app-note-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}
.note-source-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.note-source-mesa .note-source-badge {
  background: var(--c-primary-light);
  color: var(--c-primary);
}
.note-source-acolhimento .note-source-badge {
  background: #dcfce7;
  color: #16a34a;
}

/* Divider */
.app-divider {
  border: none;
  border-top: 1.5px solid var(--c-border);
  margin: 1.5rem 0;
}

/* Animal block — registration form */
.app-animal-block {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.app-animal-block .block-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--c-text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

/* Tutor type tabs — registration form */
.app-type-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.app-type-tab {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-2);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: all 0.15s;
}
.app-type-tab.active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

/* Empty state */
.app-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
}
.app-empty img  { max-width: 180px; margin-bottom: 1.5rem; opacity: 0.65; }
.app-empty h2   { font-size: 1.1rem; color: var(--c-primary); font-weight: 700; margin-bottom: 0.35rem; }
.app-empty p    { font-size: 0.85rem; color: var(--c-text-2); margin: 0; }

/* Alert tweaks */
.alert { border-radius: var(--radius-sm); border: none; font-size: 0.9rem; }

/* Custom checkbox / radio */
.app-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s;
}
.app-check input  { width: 18px; height: 18px; accent-color: var(--c-primary); }
.app-check label  { font-size: 0.9rem; font-weight: 600; cursor: pointer; margin: 0; color: var(--c-text); }
.app-check:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-light); }

/* Progress bar */
.app-progress {
  height: 6px;
  border-radius: 100px;
  background: var(--c-border);
  overflow: hidden;
  margin-top: 0.4rem;
}
.app-progress-bar {
  height: 100%;
  border-radius: 100px;
  background: var(--c-primary);
  transition: width 0.4s ease;
}

/* Tutor search result card */
.tutor-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 0.65rem;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.tutor-card.selected { border-color: var(--c-primary); background: var(--c-primary-light); }
.tutor-card .tutor-name { font-size: 0.95rem; font-weight: 600; color: var(--c-primary); margin-bottom: 2px; }
.tutor-card .tutor-sub  { font-size: 0.82rem; color: var(--c-text-2); margin: 0; }

/* Animal card — tutor detail */
.app-animal-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.app-animal-card .animal-name { font-size: 1rem; font-weight: 700; color: var(--c-primary); margin: 0; }
.app-animal-card .animal-meta { font-size: 0.82rem; color: var(--c-text-2); margin: 0.2rem 0 0; }
.animal-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  background: var(--c-primary-light);
  color: var(--c-primary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.animal-action-btn:hover { background: #dde6f9; color: var(--c-primary); }
.animal-action-btn.danger { background: #fee2e2; color: #dc2626; }
.animal-action-btn.danger:hover { background: #fecaca; color: #dc2626; }

/* Logout button */
.logout-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--c-text-2);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.logout-btn:hover { color: #dc2626; }

/* ── Auditoria ─────────────────────────────────────────────────────────────── */

/* Ícone circular por categoria */
.audit-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.audit-icon-green  { background: #dcfce7; color: #16a34a; }
.audit-icon-blue   { background: var(--c-primary-light); color: var(--c-primary); }
.audit-icon-red    { background: #fee2e2; color: #dc2626; }
.audit-icon-yellow { background: #fef9c3; color: #b45309; }

/* Cabeçalho do card */
.audit-action-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.audit-header-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--c-text);
}

/* Mensagem inline de cards simples */
.audit-simple-msg {
  margin: 0.45rem 0 0 3rem;
  font-size: 0.8rem;
  color: var(--c-text-2);
}

/* Corpo expansível */
.audit-diff { display: none; }
.audit-toggle ion-icon { transition: transform 0.2s ease; display: block; }
.audit-toggle[aria-expanded="true"] ion-icon { transform: rotate(180deg); }

.audit-body {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1.5px solid var(--c-border);
}

/* Linha de contexto (nome do animal) */
.audit-context-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-text-2);
  margin-bottom: 0.65rem;
}

/* Título de seção dentro do corpo */
.audit-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 0.65rem 0 0.35rem;
}
.audit-section-title:first-child { margin-top: 0; }

/* Tabela de diff (ANTES / DEPOIS) */
.audit-diff-table {
  width: 100%;
  border-collapse: collapse;
}
.audit-diff-table th {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: left;
  padding: 0 0.4rem 0.4rem;
}
.audit-diff-table th:first-child { padding-left: 0; }
.audit-diff-table td {
  padding: 0.28rem 0.4rem;
  font-size: 0.82rem;
  vertical-align: top;
  border-top: 1px solid var(--c-border);
}
.audit-diff-table td:first-child { padding-left: 0; }
.audit-diff-table .diff-field {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--c-text-2);
  white-space: nowrap;
  padding-right: 0.75rem;
}
.audit-diff-table .diff-before { color: #dc2626; }
.audit-diff-table .diff-after  { color: #16a34a; }

/* Bloco de nota */
.audit-note-block {
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--c-border);
}

/* Lista de animais */
.audit-animal-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--c-border);
  font-size: 0.82rem;
}
.audit-animal-item:last-child { border-bottom: none; }
.audit-animal-icon {
  color: var(--c-text-3);
  font-size: 0.9rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

/* Bloco de pares chave-valor */
.audit-kv-block { width: 100%; }
.audit-kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid var(--c-border);
  font-size: 0.82rem;
}
.audit-kv-row:last-child { border-bottom: none; }
.audit-kv-row span:first-child {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--c-text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.audit-kv-row span:last-child {
  text-align: right;
  word-break: break-all;
}
