:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #16795b;
  --accent-dark: #0f6048;
  --danger: #aa312b;
  --danger-bg: #fff2f0;
  --success-bg: #edf8f3;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0;
}

.header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.top-nav {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.top-nav a.active {
  background: var(--accent);
  color: #fff;
}

.toolbar {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

.search {
  display: flex;
  gap: 8px;
  width: min(520px, 100%);
}

.search input {
  min-width: 0;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  font-size: 14px;
}

.message.error {
  border-color: #f0b5b0;
  background: var(--danger-bg);
  color: var(--danger);
}

.message.success {
  border-color: #bbdfd1;
  background: var(--success-bg);
  color: var(--accent-dark);
}

.register-flow,
.create,
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.register-flow {
  display: grid;
  gap: 16px;
  padding: 16px;
  margin-bottom: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-title h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef1f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.success {
  background: var(--success-bg);
  color: var(--accent-dark);
}

.badge.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.loading {
  background: #eef5ff;
  color: #275f9f;
}

.cpf-check,
.details-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.details-grid {
  grid-template-columns: 1.4fr 1fr 1fr 1fr auto;
}

.flow-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.flow-status.success {
  color: var(--accent-dark);
}

.flow-status.error {
  color: var(--danger);
}

.create {
  padding: 16px;
  margin-bottom: 18px;
}

.create form {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.password-rules {
  display: grid;
  gap: 6px;
  margin: 2px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  list-style: none;
  text-transform: none;
}

.password-rules li {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 18px;
}

.password-rules li::before {
  width: 16px;
  font-weight: 900;
}

.password-rules li.valid {
  color: var(--accent-dark);
}

.password-rules li.valid::before {
  content: "✓";
}

.password-rules li.invalid {
  color: var(--danger);
}

.password-rules li.invalid::before {
  content: "×";
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--text);
  font: inherit;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 121, 91, 0.13);
}

button {
  height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:disabled:hover {
  background: var(--accent);
}

button.ghost {
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  font-size: 13px;
}

button.ghost:hover {
  border-color: #f0b5b0;
  background: var(--danger-bg);
}

.table-wrap {
  overflow: hidden;
}

.table-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.table-head strong {
  color: var(--text);
  font-size: 22px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.actions {
  width: 100px;
  text-align: right;
}

.actions form {
  margin: 0;
}

.empty {
  height: 120px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .header,
  .search {
    align-items: stretch;
    flex-direction: column;
  }

  .top-nav {
    width: 100%;
  }

  .top-nav a {
    flex: 1;
    justify-content: center;
  }

  .section-title,
  .cpf-check,
  .details-grid,
  .create form {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 760px;
  }
}
