:root {
  --bg: #fff;
  --fg: #171717;
  --muted: #737373;
  --border: #e5e5e5;
  --soft: #fafafa;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: #f5f5f5;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.muted { color: var(--muted); font-size: 0.9rem; }
.meta { color: var(--muted); font-size: 0.875rem; margin-top: 0.5rem; }

.home {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.home-inner { max-width: 32rem; text-align: center; }
.home h1 { font-size: 2.25rem; margin: 0.5rem 0; letter-spacing: -0.02em; }
.lead { color: var(--muted); font-size: 0.9rem; }
.home-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-top: 2rem;
  font-size: 0.9rem;
}
.btn {
  background: #171717;
  color: #fff !important;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none !important;
}
.btn:hover { background: #404040; }

.topbar { border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand { font-weight: 600; letter-spacing: -0.02em; text-decoration: none !important; }
.topbar nav { display: flex; gap: 1rem; font-size: 0.875rem; color: var(--muted); }

.legal {
  max-width: 48rem;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}
.legal h1 {
  font-size: 1.875rem;
  margin: 0.5rem 0 0;
  letter-spacing: -0.02em;
}
.legal section { margin-top: 2rem; }
.legal h2 { font-size: 1.125rem; margin: 0 0 0.75rem; }
.legal p, .legal li { font-size: 0.875rem; color: #262626; }
.legal ul { padding-left: 1.25rem; }
.legal li { margin: 0.35rem 0; }
#exclusao-de-dados { scroll-margin-top: 5rem; }

.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.admin { display: flex; min-height: 100vh; background: var(--soft); }
.sidebar {
  width: 14rem;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.5rem; flex: 1; }
.sidebar-head {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-head p { margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--muted); }
.sidebar nav a {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #404040;
  text-decoration: none !important;
}
.sidebar nav a:hover, .sidebar nav a.active { background: #f5f5f5; }
.sidebar-logout { margin-top: auto; color: var(--muted) !important; }
.admin-main { flex: 1; padding: 1.5rem; }
.admin-main h1 { font-size: 1.25rem; margin: 0 0 0.5rem; letter-spacing: -0.02em; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 { margin-bottom: 0.25rem; }
.page-head .btn { border: 0; cursor: pointer; font-size: 0.875rem; }
.page-head .btn:disabled { opacity: 0.45; cursor: not-allowed; }

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.field-inline {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 12rem;
  flex: 1;
}
.field-inline input,
.field-inline select {
  font: inherit;
  font-size: 0.875rem;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  background: #fff;
}

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  background: var(--soft);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.cell-sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem !important; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef9c3; color: #854d0e; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f5f5f5; color: #525252; }

.alert {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  background: #fff;
}
.alert-ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.alert-err { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.metric {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.metric-val { font-size: 1.35rem; font-weight: 650; letter-spacing: -0.03em; }
.metric-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.panel-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: #404040;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
  padding: 1rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.field-span { grid-column: 1 / -1; }
.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: 0.875rem;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  background: #fff;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 5rem; }
.hint { font-size: 0.75rem; color: var(--muted); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: #404040;
}
.btn-ghost:hover { background: #f5f5f5; }
.actions { white-space: nowrap; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.cell-clip {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-reveal {
  display: inline-block;
  margin-top: 0.35rem;
  word-break: break-all;
  background: #fff;
  border: 1px dashed #86efac;
  padding: 0.35rem 0.5rem;
}
.readonly-body {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: #404040;
  max-width: 22rem;
}
.toolbar-form { display: flex; flex-wrap: wrap; gap: 1rem; flex: 1; }

.modal {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  max-width: 32rem;
  width: calc(100% - 2rem);
}
.modal::backdrop { background: rgba(0,0,0,0.35); }
.modal-inner { margin: 0; }
.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.modal-foot { border-bottom: 0; border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-head h2 { margin: 0; font-size: 1rem; }

.json-log {
  margin: 0;
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  background: #0a0a0a;
  color: #e5e5e5;
  overflow: auto;
  max-height: 28rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.log-list { border-top: 1px solid var(--border); }
.log-item { border-bottom: 1px solid var(--border); }
.log-item summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
}
.log-item summary::-webkit-details-marker { display: none; }
.log-item[open] summary { border-bottom: 1px solid var(--border); background: var(--soft); }

@media (max-width: 720px) {
  .admin { flex-direction: column; }
  .sidebar { width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
