/* Shared controls: the same rhythm from client records to closing a period. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition:
    background 0.16s,
    border-color 0.16s,
    transform 0.12s var(--ease);
}
.btn:hover {
  background: var(--surface-soft);
  border-color: var(--subtle);
  text-decoration: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled:active {
  transform: none;
}
.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px #123b2712;
}
.btn--primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn--ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.btn--ghost:hover {
  border-color: transparent;
  background: var(--surface-soft);
}
.btn--danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}
.btn--danger:hover {
  background: var(--danger-soft);
  border-color: transparent;
}
.btn--sm {
  padding: 7px 12px;
  min-height: 34px;
  font-size: 12px;
}
.btn--block {
  width: 100%;
}
.btn .af-icon {
  width: 17px;
  height: 17px;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}
.field {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  background: var(--control-bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  transition:
    border-color 0.16s,
    box-shadow 0.16s;
}
.field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
textarea.field {
  resize: vertical;
  min-height: 96px;
}
.field__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 6px;
}
.field__label:first-child {
  margin-top: 0;
}
.field__label > .field {
  margin-top: 6px;
}
select.field {
  cursor: pointer;
  padding-right: 24px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card__body {
  padding: 24px;
}
.card__title {
  font-size: 16px;
  margin-bottom: 4px;
}
.section__title {
  font-size: 16px;
  margin: 0 0 12px;
}
.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.section__head p {
  margin: 4px 0 0;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  flex: none;
}
.avatar--lg {
  width: 80px;
  height: 80px;
  font-size: 26px;
  border-radius: 20px;
}
.avatar--sm {
  width: 24px;
  height: 24px;
  font-size: 9px;
  border-radius: 8px;
}
.progress {
  height: 5px;
  border-radius: 99px;
  background: var(--surface-soft);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.table th,
.table td {
  padding: 16px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.table th {
  background: var(--surface-soft);
  font-size: 10px;
  letter-spacing: 0.065em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.table tbody tr:hover {
  background: color-mix(in srgb, var(--primary-soft) 40%, var(--surface));
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table td:last-child,
.table th:last-child {
  text-align: right;
}
.table .btn {
  min-height: 32px;
}
.table-wrap {
  overflow: auto;
  border-radius: var(--radius-lg);
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
}
.modal.is-open {
  display: block;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 29, 23, 0.4);
  backdrop-filter: blur(3px);
}
.modal__panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-soft);
}
.modal__head h2 {
  font-size: 19px;
}
.modal__head > .icon-btn:last-child {
  margin-left: auto;
}
.modal__body {
  padding: 24px;
}
.modal__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-soft);
  flex-wrap: wrap;
}
.modal__close {
  margin-left: auto;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  max-width: calc(100vw - 32px);
  background: var(--ink);
  color: var(--surface);
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s,
    transform 0.18s;
  z-index: 100;
  font-size: 13px;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.err {
  background: var(--danger);
  color: var(--surface);
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  padding: 40px 24px;
  font-size: 13px;
  line-height: 1.6;
}
.empty .af-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
  color: var(--primary-ink);
}
.skeleton {
  color: var(--muted);
  padding: 24px;
  font-size: 13px;
}
.skeleton::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 10px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: af-spin 1s linear infinite;
}
@keyframes af-spin {
  to {
    transform: rotate(360deg);
  }
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.gallery-card {
  position: relative;
  text-align: left;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 24px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition:
    border-color 0.16s,
    box-shadow 0.16s;
}
.gallery-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.gallery-card__title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  word-break: break-word;
}
.gallery-card__meta {
  font-size: 12px;
  color: var(--muted);
}
.gallery-card__acts {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  opacity: 0;
}
.gallery-card:hover .gallery-card__acts,
.gallery-card:focus-within .gallery-card__acts {
  opacity: 1;
}
.gallery-card__act {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 0;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.gallery-card__act.del:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.gallery-card--add {
  align-items: center;
  justify-content: center;
  text-align: center;
  border-style: dashed;
  color: var(--muted);
  font-weight: 500;
  background: transparent;
}
.detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.detail-head h1 {
  font-size: 24px;
}
.err:not(#toast) {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}
@media (max-width: 600px) {
  .btn {
    min-height: 44px;
  }
  .btn--sm {
    min-height: 40px;
  }
  .card__body {
    padding: 20px;
  }
  .modal__body,
  .modal__head {
    padding: 20px;
  }
  .modal__foot {
    padding: 16px 20px;
  }
  .table td,
  .table th {
    padding: 12px 16px;
  }
  .gallery-card__acts {
    opacity: 1;
  }
  .gallery {
    grid-template-columns: 1fr;
  }
  .field {
    font-size: 16px;
  }
}

/* Comunicados persistentes, com confirmação individual de leitura. */
.avisos-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow-y: auto; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 16px 48px #0002; }
.avisos-dialog::backdrop { background: #10231dcc; }
.avisos-head, .aviso-admin { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.avisos-head h2 { margin: 4px 0 0; color: var(--ink); }
.avisos-list { display: grid; gap: 16px; margin: 20px 0; }
.aviso-item { border: 1px solid var(--border); border-left: 4px solid var(--yellow); border-radius: 8px; padding: 18px; background: var(--surface-soft); }
.aviso-item h3 { margin: 8px 0; color: var(--ink); overflow-wrap: anywhere; }
.aviso-mensagem { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.aviso-confirm { display: flex; align-items: center; gap: 10px; padding: 12px 0 0; cursor: pointer; font-weight: 600; color: var(--primary); }
.aviso-confirm input { width: 20px; height: 20px; accent-color: var(--primary); }
.aviso-admin { margin-top: 16px; flex-wrap: wrap; }
#aviso-form { border-top: 1px solid var(--border); padding-top: 20px; display: grid; gap: 12px; }
#aviso-form .field { width: 100%; margin-top: 6px; }
.aviso-status { color: var(--primary); }
@media(max-width: 480px) { .avisos-dialog { padding: 18px; } .avisos-head { align-items: flex-start; } }
