@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* shadcn/ui design tokens */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;

  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;

  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;

  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;

  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;

  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;

  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;

  --destructive: 0 72% 42%;
  --destructive-foreground: 0 0% 98%;

  --success: 142 72% 29%;
  --success-foreground: 0 0% 98%;

  --border: 240 5.9% 90%;
  --input: 240 5% 58%;
  --ring: 240 5.9% 10%;

  --radius: 0.5rem;
}

* { box-sizing: border-box; border-color: hsl(var(--border)); }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:where(a, button, input, select, textarea, [tabindex]) {
  scroll-margin-top: 72px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header / Navbar ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(8px);
}

header > .container {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.brand-sep {
  width: 1px;
  height: 18px;
  background: hsl(var(--border));
  margin: 0 4px;
}

.brand-sub {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}

header nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

header nav a {
  font-size: 13.5px;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  padding: 6px 10px;
  border-radius: calc(var(--radius) - 2px);
  transition: color 0.15s ease, background 0.15s ease;
}

header nav a:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}

/* ---------- Layout ---------- */

main {
  max-width: 768px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

main.wide {
  max-width: 1200px;
}

main.login-wrap,
main.thanks-wrap {
  max-width: none;
  margin: 0;
}

/* ---------- Typography ---------- */

h1, h2, h3 {
  letter-spacing: -0.02em;
  margin: 0;
}

.heading-lg { font-size: 30px; font-weight: 600; line-height: 1.2; }
.heading-md { font-size: 24px; font-weight: 600; line-height: 1.25; }
.heading-sm { font-size: 18px; font-weight: 600; line-height: 1.3; }

.muted {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
}

/* ---------- Page header (titles above cards) ---------- */

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 8px;
}

.page-header p {
  color: hsl(var(--muted-foreground));
  font-size: 15px;
  max-width: 580px;
}

/* ---------- Card ---------- */

.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.card-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid hsl(var(--border));
}

.card-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
}

.card-header p {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  margin: 0;
}

.card-content {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Form ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field-cep {
  max-width: 220px;
}

.form-instructions {
  margin: 0 0 20px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}

.field-hint,
.field-error {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
}

.field-hint {
  color: hsl(var(--muted-foreground));
}

.field-error {
  color: hsl(var(--destructive));
  font-weight: 500;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .row { grid-template-columns: 1fr; }
  .field-cep { max-width: none; }
}

label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: hsl(var(--foreground));
}

label .req {
  color: hsl(var(--destructive));
  margin-left: 2px;
}

.input,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="password"],
input[type="search"],
select,
textarea {
  display: flex;
  width: 100%;
  min-height: 36px;
  height: auto;
  padding: 7px 12px;
  font: inherit;
  font-size: 14px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  padding: 10px 12px;
  min-height: 80px;
  resize: vertical;
}

input::placeholder, textarea::placeholder {
  color: hsl(var(--muted-foreground));
}

input:focus, select:focus, textarea:focus {
  outline: 3px solid hsl(var(--ring));
  outline-offset: 3px;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring) / 0.4);
}

input:disabled, select:disabled, textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: hsl(var(--destructive));
  box-shadow: 0 0 0 1px hsl(var(--destructive));
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23737380' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

/* Checkbox */

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13.5px;
  color: hsl(var(--foreground));
  cursor: pointer;
  flex-wrap: wrap;
}

.checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1px solid hsl(var(--input));
  border-radius: 4px;
  background: hsl(var(--background));
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.checkbox input[type="checkbox"]:hover {
  border-color: hsl(var(--ring));
}

.checkbox input[type="checkbox"]:checked {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid hsl(var(--primary-foreground));
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox input[type="checkbox"]:focus-visible {
  outline: 3px solid hsl(var(--ring));
  outline-offset: 3px;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring) / 0.4);
}

.checkbox label, .checkbox span {
  cursor: pointer;
  font-weight: 400;
  line-height: 1.5;
  flex: 1;
}

.checkbox .field-error {
  flex: 0 0 100%;
  padding-left: 26px;
}

.consent-fields {
  min-width: 0;
  margin: 16px 0 0;
  padding: 16px 0 0;
  border: 0;
  border-top: 1px solid hsl(var(--border));
}

.consent-fields legend {
  padding: 0;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Buttons ---------- */

.btn,
button.primary,
button.ghost,
button.outline,
button.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: normal;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
  height: auto;
  padding: 7px 16px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  user-select: none;
}

.btn:focus-visible,
button.primary:focus-visible,
button.ghost:focus-visible,
button.outline:focus-visible,
button.danger:focus-visible {
  outline: 3px solid hsl(var(--ring));
  outline-offset: 3px;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring) / 0.4);
}

button.primary, .btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

button.primary:hover { background: hsl(var(--primary) / 0.9); }

button.outline {
  background: hsl(var(--background));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

button.outline:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

button.ghost, .btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

button.ghost:hover {
  background: hsl(var(--accent));
}

button.danger {
  background: transparent;
  color: hsl(var(--destructive));
  border-color: hsl(var(--input));
}

button.danger:hover {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-color: hsl(var(--destructive));
}

button.sm {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 13px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-block {
  width: 100%;
}

/* ---------- Alerts ---------- */

.alert {
  position: relative;
  border-radius: calc(var(--radius) - 2px);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
}

.alert-title {
  font-weight: 500;
  margin-bottom: 2px;
}

.alert p {
  margin-top: 0;
}

.alert ul {
  margin: 8px 0 0;
  padding-left: 22px;
}

.alert.error {
  border-color: hsl(var(--destructive) / 0.5);
  background: hsl(var(--destructive) / 0.08);
  color: hsl(var(--destructive));
}

.alert.success {
  border-color: hsl(var(--success) / 0.5);
  background: hsl(var(--success) / 0.08);
  color: hsl(var(--success));
}

.alert.info {
  border-color: hsl(var(--input));
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

/* ---------- Consent box ---------- */

.consentimentos {
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 14px 16px;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  line-height: 1.55;
}

.consentimentos p { margin: 0 0 8px; }
.consentimentos p:last-child { margin-bottom: 0; }

/* ---------- Admin toolbar ---------- */

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}

.dashboard-head h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.dashboard-head p {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  margin: 0;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1 1 240px;
  min-width: 0;
  position: relative;
}

.search-wrap input {
  padding-left: 36px;
}

.search-wrap::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23737380' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat center;
  pointer-events: none;
}

/* ---------- Table ---------- */

.table-wrap {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: hsl(var(--muted) / 0.4);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
  height: 40px;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover { background: hsl(var(--muted) / 0.4); }

tbody th {
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  vertical-align: middle;
}

tbody tr:last-child th { border-bottom: none; }

.nome { font-weight: 500; }
td.muted-cell { color: hsl(var(--muted-foreground)); }

.acoes {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.acoes-header {
  text-align: right;
}

/* ---------- Badge ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  height: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid transparent;
}

/* ---------- Dialog (modal) ---------- */

.modal::backdrop {
  background: hsl(var(--foreground) / 0.5);
  backdrop-filter: blur(4px);
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  position: fixed;
  inset: 0;
  padding: 0;
  margin: auto;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.modal[open] {
  display: flex;
  flex-direction: column;
  animation: dialogIn 0.18s ease-out;
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid hsl(var(--border));
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
}

.modal-header p {
  color: hsl(var(--muted-foreground));
  font-size: 13.5px;
  margin: 0;
}

.modal-body {
  padding: 20px 24px;
  min-height: 0;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Empty state ---------- */

.empty {
  padding: 56px 24px;
  text-align: center;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--card));
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius);
}

.empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: hsl(var(--muted));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.empty-title {
  font-weight: 500;
  color: hsl(var(--foreground));
  margin-bottom: 4px;
  font-size: 15px;
}

.empty p { font-size: 13.5px; margin: 0; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-wrap > div {
  width: 100%;
  max-width: 400px;
}

.login-wrap .brand-center {
  text-align: center;
  margin-bottom: 24px;
}

.login-wrap .brand-center .brand-mark {
  width: 44px;
  height: 44px;
  font-size: 18px;
  border-radius: 8px;
  margin: 0 auto 12px;
}

.login-wrap h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
}

.login-wrap .lead {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  margin: 0;
}

/* ---------- Misc ---------- */

.separator {
  height: 1px;
  background: hsl(var(--border));
  margin: 16px 0;
}

.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-muted { color: hsl(var(--muted-foreground)); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid hsl(var(--ring));
  outline-offset: 3px;
}

@media (max-width: 500px) {
  header > .container {
    min-height: 56px;
    height: auto;
    padding: 8px 16px;
    gap: 8px 12px;
    flex-wrap: wrap;
  }

  header nav {
    margin-left: auto;
  }

  main {
    padding: 32px 16px 48px;
  }

  .card-content,
  .modal-body {
    padding: 20px 16px;
  }

  .card-footer,
  .modal-footer,
  .modal-header {
    padding-left: 16px;
    padding-right: 16px;
  }

  .modal-footer {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
