/* --- GERAL E PALETA DE CORES --- */
:root {
  /* Sua Paleta de Cores */
  --brand-blue: #0077B6;      /* Azul petróleo */
  --accent-green: #00C49A;    /* Verde menta */
  --soft-lavender: #CBA6F7;   /* Lavanda */
  --alert-coral: #FF7F7F;      /* Coral claro */
  --neutral-bg: #F2F2F2;        /* Cinza suave */

  /* Cores de apoio */
  --neutral-text: #333;
  --muted-text: #6c757d;
  --card-background: #ffffff;
  --border-color: var(--soft-lavender); /* Usando Lavanda para as bordas */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--neutral-bg); /* Usando Cinza Suave */
  color: var(--neutral-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- CABEÇALHO --- */
header {
  width: 100%;
  background: var(--card-background);
  border-bottom: 1px solid var(--border-color); /* Usando Lavanda */
}

.topbar {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 80px;
}

.brand-logo img {
  height: 42px;
  width: auto;
  display: block;
}

.topbar .welcome {
  margin: 0 auto;
  font-weight: 600;
  color: var(--muted-text);
}

header nav button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border-color); /* Usando Lavanda */
  background-color: #f5f0fe; /* Tom bem claro de Lavanda */
  color: #583a8e; /* Tom escuro de Lavanda para texto */
  cursor: pointer;
  margin-left: 0.5rem;
  transition: all 0.2s ease;
}

header nav button.danger {
  background-color: var(--alert-coral); /* Usando Coral Claro */
  color: #fff;
  border-color: var(--alert-coral);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

header nav button:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}
header nav button.danger:hover {
  filter: brightness(0.95);
  border-color: var(--alert-coral);
  color: #fff;
}


/* --- CONTEÚDO PRINCIPAL E CARDS --- */
main.wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center; /* Centraliza os cards */
  padding: 2rem 1rem;
  width: 100%;
}

.card {
  background: var(--card-background);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(203, 166, 247, 0.2); /* Sombra suave com tom de Lavanda */
  padding: 2rem;
  width: 100%;
  max-width: 450px;
  border: 1px solid var(--border-color); /* Usando Lavanda */
  margin-bottom: 2rem;
}

#view-signup .card { max-width: 700px; }
#client .card { max-width: 700px; }
#admin .card { max-width: 900px; }


.card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-align: left;
}

/* --- FORMULÁRIOS E BOTÕES --- */
.row { display: grid; gap: 1rem; }
.row2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

label {
  font-size: 13px;
  color: var(--muted-text);
  display: block;
  margin-bottom: 0.5rem;
}

label .required {
  color: var(--alert-coral); /* Usando Coral Claro */
  margin-left: 4px;
  font-weight: bold;
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #fff;
  font-size: 15px;
  font-family: inherit;
}

input:not([type="file"]) {
  border: none;
  border-bottom: 1px solid var(--border-color);
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
}

input[type="file"] {
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: 8px;
}
input[type="file"]::file-selector-button {
  font-family: inherit;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: none;
  background-color: #f5f0fe;
  color: #583a8e;
  cursor: pointer;
  margin-right: 1rem;
}


input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 2px rgba(0, 119, 182, 0.2);
}
input:not([type="file"]):focus {
  border-bottom-color: var(--brand-blue);
  box-shadow: none;
}


.password-wrap { position: relative; }
.password-wrap .toggle { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; padding: 0; font-size: 12px; background: transparent; border: none; color: var(--muted-text); cursor: pointer; }

.actions { display: flex; gap: 1rem; align-items: center; margin-top: 1.5rem; flex-wrap: wrap; }
.modal-actions { justify-content: space-between; }


.btn { font-family: inherit; font-weight: 700; font-size: 15px; padding: 0.75rem 1.5rem; border-radius: 8px; border: none; cursor: pointer; background: var(--brand-blue); color: #fff; transition: filter 0.2s ease; }
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background-color: #f5f0fe; color: #583a8e; border: 1px solid var(--border-color); }
.btn.secondary:hover { filter: brightness(0.95); }
.btn.ghost { background: transparent; color: var(--neutral-text); border: 1px solid var(--border-color); }
.btn.danger { background-color: transparent; color: var(--alert-coral); border: 1px solid var(--alert-coral); }
.btn.danger:hover { background-color: var(--alert-coral); color: white; }


a.link, .hint a { color: var(--brand-blue); text-decoration: none; font-weight: 600; font-size: 14px; }
a.link:hover, .hint a:hover { text-decoration: underline; }

.hint { font-size: 14px; color: var(--muted-text); }


/* --- RODAPÉ --- */
footer { width: 100%; text-align: center; padding: 1.5rem; font-size: 13px; color: var(--muted-text); margin-top: auto; }


/* --- ELEMENTOS ESPECÍFICOS DA UI --- */
.kpi { display: flex; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 100px; background-color: #e0f8f3; color: #005f4b; font-weight: 700; font-size: 12px; border: 1px solid var(--accent-green); }
#lib-grid {
  grid-template-columns: none; /* Remove a grade */
}

/* --- PAGINAÇÃO DA BIBLIOTECA --- */
.lib-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}
.lib-page-info {
  font-size: 13px;
  color: var(--muted-text);
  min-width: 100px;
  text-align: center;
}

/* --- ESTILOS PARA BIBLIOTECA (TABELA) --- */
.library-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 13px; /* Tamanho de fonte um pouco menor */
  table-layout: fixed; /* Ajuda o navegador a renderizar a tabela mais rápido */
}

.library-table th, .library-table td {
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  word-wrap: break-word; /* Garante que textos longos quebrem a linha */
}

.library-table th {
  background-color: #f5f0fe;
  font-weight: 600;
}

.library-table tbody tr:nth-of-type(even) {
  background-color: #f8fafc;
}

.library-table .caption-cell {
  max-width: 220px;
  cursor: pointer;
}
.library-table .caption-cell .caption-preview {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  font-size: 13px;
  color: var(--muted-text);
}

/* Modal de compra */
.buy-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.buy-options-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.buy-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: inherit;
}
.buy-option-btn:hover {
  border-color: var(--primary);
  background: #f5f3ff;
}
.buy-option-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.buy-option-desc {
  font-size: 12px;
  color: var(--muted-text);
}
.buy-option-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}
@media (max-width: 640px) {
  .buy-options-3 { grid-template-columns: 1fr 1fr; }
}

.library-thumb {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.btn-delete-item {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--alert-coral);
  background-color: transparent;
  color: var(--alert-coral);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-delete-item:hover {
  background-color: var(--alert-coral);
  color: #fff;
}


/* --- ESTILOS PARA O CARD "MINHA MARCA" --- */
.brand-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.brand-content { display: grid; grid-template-columns: 1fr 2fr; gap: 2rem; align-items: flex-start; }
.brand-logo-preview img { width: 150px; height: 150px; object-fit: contain; border: 1px solid var(--border-color); border-radius: 8px; padding: 0.5rem; }
.brand-details { display: flex; flex-direction: column; gap: 1.5rem; }
.color-swatches { display: flex; gap: 1rem; align-items: center; }
.color-swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.placeholder { font-style: italic; color: var(--muted-text); font-size: 14px; }

/* --- ESTILOS PARA SUGESTÕES DE CIDADE --- */
#city-suggestions { position: absolute; width: 100%; background-color: white; border: 1px solid var(--border-color); border-top: none; border-radius: 0 0 8px 8px; z-index: 10; max-height: 150px; overflow-y: auto; }
#city-suggestions div { padding: 8px 12px; cursor: pointer; }
#city-suggestions div:hover { background-color: #f5f0fe; }
.admin-feedback-item{border:1px solid var(--border-color);border-radius:12px;padding:15px;margin:10px 0;background:#fff}.admin-feedback-head{display:flex;justify-content:space-between;gap:12px;align-items:center}.admin-feedback-item p{margin:10px 0;white-space:pre-wrap}.admin-feedback-item small{color:var(--muted-text)}.admin-feedback-head select,#feedback-filter{padding:7px 9px;border:1px solid var(--border-color);border-radius:8px;background:#fff}
.admin-issue-card{border:1px solid var(--border-color);border-left:5px solid #8b6bcf;border-radius:12px;padding:15px;margin:10px 0;background:#fff}.admin-issue-card p{margin:10px 0}.admin-issue-card small{color:var(--muted-text)}.admin-issue-warning{border-left-color:#d08a1f}.admin-issue-critical{border-left-color:#d64545}.admin-issue-info{border-left-color:#4c78c9}

/* --- ESTILOS PARA PAINEL DE ADMIN --- */
.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.admin-table th, .admin-table td { border: 1px solid var(--border-color); padding: 8px 12px; text-align: left; font-size: 14px; }
.admin-table th { background-color: #f5f0fe; }
.admin-table code { background-color: #eee; padding: 2px 4px; border-radius: 4px; }
.admin-table .actions-cell { white-space: nowrap; vertical-align: middle; }
.admin-table .actions-cell button { font-size: 12px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border-color); cursor: pointer; background-color: #fff; margin-right: 4px; }
.admin-table .actions-cell button:hover { background-color: #f5f0fe; }
.brain-architecture-note { margin: 18px 0 24px; padding: 16px; border: 1px solid #ded5ff; border-radius: 14px; background: linear-gradient(135deg, #faf8ff, #fff); }
.brain-architecture-note > strong { display: block; margin-bottom: 10px; color: var(--text); }
.brain-architecture-note p { margin: 10px 0 0; color: var(--muted-text); font-size: 13px; line-height: 1.5; }
.brain-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.brain-legend > span { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted-text); }
.brain-badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 8px; border-radius: 999px; font-size: 11px; line-height: 1; font-style: normal; font-weight: 800; white-space: nowrap; }
.brain-editorial { color: #1e5a43; background: #ddf8eb; border: 1px solid #a9e6ca; }
.brain-limited { color: #654213; background: #fff2ce; border: 1px solid #f0d48b; }
.brain-protected { color: #6a2940; background: #ffe2ec; border: 1px solid #f3b7ca; }
.brain-draft { color:#8b5100; background:#fff0d8; border:1px solid #f2c879; }
.brain-published { color:#17694f; background:#e4f8ef; border:1px solid #9bd7c1; }
.admin-content-modal{max-width:980px;max-height:88vh;overflow:auto}.admin-diff-grid{display:grid;gap:1rem}.admin-diff-grid article{display:grid;grid-template-columns:160px 1fr 1fr;gap:.75rem;border:1px solid var(--border-color);border-radius:12px;padding:.8rem}.admin-diff-grid h3{font-size:.85rem;text-transform:capitalize}.admin-diff-grid pre,.admin-version-card pre{white-space:pre-wrap;word-break:break-word;background:#171326;color:#f7f4ff;border-radius:8px;padding:.75rem;max-height:260px;overflow:auto}.admin-version-card{display:grid;gap:.7rem;border:1px solid var(--border-color);border-radius:12px;padding:1rem;margin:.7rem 0}.admin-version-card>div{display:flex;justify-content:space-between;gap:1rem}.admin-version-card small{color:var(--muted-text)}
@media(max-width:760px){.admin-diff-grid article{grid-template-columns:1fr}.admin-version-card>div{display:grid}}
.brain-draft { color:#8b5100; background:#fff0d8; border:1px solid #f2c879; }
.brain-published { color:#17694f; background:#e4f8ef; border:1px solid #9bd7c1; }
input[readonly], select:disabled { background: #f3f1f7; color: #696475; cursor: not-allowed; }

/* --- ESTILOS PARA O MODAL DE ADMIN --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 100; padding: 1rem; }
.modal-content { width: 90%; max-width: 700px; }
.modal-content h2 {
  margin-bottom: 1.5rem; /* Adiciona espaçamento abaixo do título do modal */
}
.form-hint {
  font-size: 12px;
  color: var(--muted-text);
  margin-top: 4px;
  display: block;
}

/* --- ESTILOS PARA O WIZARD DE CRIAÇÃO --- */
.wizard-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
#wizard-step-indicator { font-weight: 600; color: var(--muted-text); }

#wizard-content { min-height: 200px; }
#wizard-content h2 { margin-bottom: 1.5rem; font-size: 20px; }
#wizard-content h3 { font-size: 16px; font-weight: 600; color: var(--muted-text); border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; margin-bottom: 1rem; }

.wizard-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.wizard-section-desc { font-size: 13px; color: var(--muted-text); margin: -4px 0 12px; font-style: italic; }
.wizard-option-btn { padding: 1.5rem 1rem; border: 2px solid var(--border-color); border-radius: 12px; background-color: transparent; font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.2s ease; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem; }
.wizard-option-btn:hover { border-color: var(--brand-blue); background-color: #f0f8ff; color: var(--brand-blue); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 119, 182, 0.1); }
.wizard-option-btn.selected { border-color: var(--brand-blue); background-color: #f0f8ff; color: var(--brand-blue); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 119, 182, 0.15); }
.wob-label { font-size: 15px; font-weight: 600; line-height: 1.3; }
.wob-desc { font-size: 11px; font-weight: 400; color: var(--muted-text); line-height: 1.3; font-style: italic; }
.wob-sublabel { font-size: 12px; font-weight: 400; color: var(--muted-text); line-height: 1.3; }
.wizard-option-btn.selected .wob-desc,
.wizard-option-btn.selected .wob-sublabel { color: inherit; opacity: 0.75; }

#wizard-nav { margin-top: 2rem; display: flex; justify-content: space-between; }

.wizard-step-content { display: flex; flex-direction: column; gap: 1.5rem; margin-top: 1rem; }

/* --- UTILITÁRIOS E DIVERSOS --- */
.hidden { display: none !important; }

.btn:disabled { background-color: var(--muted-text); cursor: not-allowed; filter: none; }
.btn:disabled:hover { filter: none; }

.wizard-summary { list-style-type: none; padding: 0; margin: 1rem 0; background-color: #f5f0fe; border-radius: 8px; border: 1px solid var(--border-color); padding: 1rem; }
.wizard-summary li { font-size: 15px; color: var(--neutral-text); padding: 0.5rem 0; }
.wizard-summary li + li { border-top: 1px solid var(--border-color); }
.wizard-summary li strong { color: #583a8e; margin-right: 8px; }

.refinements-container { display: flex; flex-direction: column; gap: 1.5rem; margin-top: 1rem; }
.refinement-subcat-header { font-size: 13px; font-weight: 700; color: var(--brand-blue); text-transform: uppercase; letter-spacing: .06em; margin-bottom: -0.5rem; padding-bottom: 6px; border-bottom: 1px solid var(--border-color); }
.refinements-subcat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.6rem; }
.refinement-item { display: flex; align-items: center; background-color: #f8fafc; border: 1px solid var(--border-color); border-radius: 8px; padding: 0.75rem; transition: all 0.2s ease; }
.refinement-item:has(input:checked) { background-color: #f5f0fe; border-color: var(--brand-blue); }
.refinement-item input[type="checkbox"] { width: 1.25em; height: 1.25em; margin-right: 0.75rem; accent-color: var(--brand-blue); cursor: pointer; }
.refinement-item label { font-size: 14px; color: var(--neutral-text); margin-bottom: 0; cursor: pointer; display: flex; flex-direction: column; gap: 0.15rem; }
.ref-label { font-weight: 500; line-height: 1.3; }
.ref-desc { font-size: 11px; font-weight: 400; color: var(--muted-text); line-height: 1.2; font-style: italic; }

/* --- ESTILOS PARA O MODAL DE RESULTADO --- */
.result-content { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin: 1.5rem 0; }
@media (min-width: 600px) { .result-content { grid-template-columns: 250px 1fr; } }
.result-image-wrapper img { width: 100%; height: auto; aspect-ratio: auto; max-height: 480px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border-color); background: #f5f5f5; }
.result-caption-wrapper h3 { font-size: 16px; color: var(--muted-text); margin-bottom: 0.5rem; }
#result-caption-editor {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}
#btn-copy-caption { display: inline-flex; align-items: center; gap: 8px; margin-top: 1rem; }

/* --- ESTILOS PARA O PAINEL DE LÓGICA DO PROMPT --- */
.prompt-logic-card h1 { margin-bottom: 0.5rem; }
.prompt-logic-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); }
.prompt-logic-section h3 { margin-bottom: 1rem; }
.prompt-logic-section p { line-height: 1.6; margin-bottom: 1rem; }
.prompt-logic-section ul { list-style-position: inside; padding-left: 0.5rem; }
.prompt-logic-section li { margin-bottom: 0.5rem; }
.prompt-template { background-color: #f8fafc; border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; font-family: 'Courier New', Courier, monospace; font-size: 13px; line-height: 1.7; white-space: pre-wrap; color: #333; }
.prompt-template .placeholder-tag { color: var(--brand-blue); background-color: #e0f2ff; padding: 2px 6px; border-radius: 4px; font-weight: bold; }

/* --- SISTEMA DE TOAST --- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  max-width: 360px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.toast-error   { background: #fee2e2; color: #7f1d1d; border-left: 4px solid #ef4444; }
.toast-info    { background: #dbeafe; color: #1e3a8a; border-left: 4px solid #3b82f6; }

/* --- MODAL DE CONFIRMAÇÃO --- */
#confirm-overlay .confirm-modal,
#compliance-overlay .compliance-modal {
  max-width: 480px;
  width: 90%;
}
.confirm-modal p,
.compliance-modal p { margin-bottom: 1rem; line-height: 1.6; }
.compliance-modal ul { list-style: disc; padding-left: 1.5rem; margin-bottom: 1rem; }
.compliance-modal li { margin-bottom: 0.4rem; line-height: 1.5; }
.compliance-check {
  display: block;
  cursor: pointer;
  font-size: 14px;
  margin-top: 0.5rem;
  line-height: 1.5;
}
.compliance-check input[type="checkbox"] {
  display: inline;
  width: auto;
  margin-right: 0.4rem;
  vertical-align: middle;
  flex-shrink: unset;
}
.compliance-check span { vertical-align: middle; }

/* --- BANNER DE UPGRADE --- */
.upgrade-banner {
  background: linear-gradient(135deg, #fff7ed, #fef3c7);
  border: 1px solid #f59e0b;
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
}
.upgrade-banner p { margin-bottom: 0.75rem; font-size: 14px; color: #92400e; }
.upgrade-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.upgrade-actions .btn { font-size: 13px; padding: 0.5rem 0.9rem; }

/* --- BOTÕES DE AÇÃO DA TABELA ADMIN --- */
.admin-action-btn {
  display: inline-block;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #f5f0fe;
  color: #583a8e;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.admin-action-btn:hover {
  background: var(--brand-blue);
  color: #fff;
  border-color: var(--brand-blue);
}
.admin-table td.actions-cell {
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1;
}
.admin-action-btn + .admin-action-btn {
  margin-left: 6px;
}

/* --- BADGES DE PLANO (admin) --- */
.plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.plan-trial   { background: #f3f4f6; color: #6b7280; }
.plan-free    { background: #dbeafe; color: #1d4ed8; }
.plan-pro     { background: #d1fae5; color: #065f46; }
.plan-premium { background: #ede9fe; color: #5b21b6; }
.plan-admin   { background: #fef3c7; color: #92400e; }

/* --- MODAL DE DETALHE DA BIBLIOTECA --- */
.lib-detail-content {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  margin: 1.25rem 0;
}
.lib-detail-image-wrap img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  object-fit: cover;
}
.lib-detail-params {
  background: #f5f0fe;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  font-size: 14px;
  line-height: 1.8;
}
.lib-detail-params strong { color: #583a8e; }
.lib-row-clickable { cursor: pointer; }
.lib-row-clickable:hover { background-color: #f5f0fe !important; }

@media (max-width: 640px) {
  .lib-detail-content { grid-template-columns: 1fr; }
  .lib-detail-image-wrap img { max-height: 220px; object-fit: contain; }
}

/* ============================================================
   RESPONSIVIDADE MOBILE — max-width: 640px
   ============================================================ */

/* Evita scroll horizontal na página inteira */
html, body { overflow-x: hidden; max-width: 100%; }
main.wrap { overflow-x: hidden; }

@media (max-width: 640px) {

  /* Header */
  .topbar {
    height: auto;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .brand-logo img { height: 32px; }
  .topbar .welcome { display: none; }
  header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
  }
  header nav button {
    font-size: 11px;
    padding: 0.35rem 0.6rem;
    margin-left: 0;
  }

  /* Layout principal */
  main.wrap { padding: 1rem 0.75rem; }

  /* Sections ocupam largura total no mobile para evitar overflow */
  #view-signup, #client, #view-admin { width: 100%; max-width: 100%; }

  /* Cards */
  .card { padding: 1.25rem; border-radius: 12px; }
  #view-signup .card,
  #client .card,
  #admin .card { max-width: 100%; }

  /* Seção de marca */
  .brand-content { grid-template-columns: 1fr; }
  .brand-logo-preview img { width: 100px; height: 100px; }

  /* Wizard */
  .wizard-options {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .wizard-option-btn {
    padding: 1rem 0.5rem;
    font-size: 14px;
  }
  .refinements-container { grid-template-columns: 1fr; }
  #wizard-nav { gap: 0.5rem; }
  #wizard-nav .btn { flex: 1; text-align: center; }

  /* Biblioteca — scroll horizontal contido */
  #lib-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .library-table { min-width: 520px; font-size: 12px; }
  .library-thumb { width: 40px; height: 40px; }

  /* Admin table — scroll horizontal contido */
  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .admin-table { min-width: 580px; font-size: 12px; }

  /* Modal de resultado — altura máxima com scroll */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-content {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    overflow-y: auto;
    padding: 1.25rem;
  }
  .result-content { grid-template-columns: 1fr; }
  .result-image-wrapper img { aspect-ratio: auto; max-height: 240px; object-fit: contain; }
  #result-caption-editor { min-height: 80px; }
  .modal-actions { flex-direction: column-reverse; gap: 0.75rem; }
  .modal-actions .btn { width: 100%; text-align: center; }

  /* Modal de compliance e confirmação — também com scroll */
  #confirm-overlay .confirm-modal,
  #compliance-overlay .compliance-modal {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    overflow-y: auto;
  }

  /* Botões de ação genéricos */
  .actions { flex-direction: column; align-items: stretch; }
  .actions .btn { width: 100%; text-align: center; }

  /* Toast */
  #toast-container { right: 0.75rem; left: 0.75rem; bottom: 1rem; }
  .toast { max-width: 100%; }

  /* Formulário de linhas */
  .row2, .row3 { grid-template-columns: 1fr; }
}

/* ── LGPD / Termos ─────────────────────────────────────────── */
.lgpd-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 1rem 0 0.5rem;
  padding: 1rem;
  background: #f8f7ff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.lgpd-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
}
.lgpd-label input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.lgpd-label .link {
  font-weight: 600;
}

/* Modal legal */
.legal-modal {
  max-width: 680px;
  max-height: 88vh;
  overflow-y: auto;
}
.legal-date {
  font-size: 13px;
  color: var(--muted-text);
  margin-bottom: 1.25rem;
}
.legal-body h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 1.25rem 0 0.4rem;
  color: var(--text);
}
.legal-body p, .legal-body li {
  font-size: 13.5px;
  line-height: 1.7;
  color: #374151;
}
.legal-body ul {
  padding-left: 1.25rem;
  margin: 0.4rem 0;
}
.legal-body li { margin-bottom: 0.25rem; }
.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0.5rem 0;
}
.legal-table th, .legal-table td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.legal-table th {
  background: #f3f4f6;
  font-weight: 600;
}
@media (max-width: 640px) {
  .legal-modal { max-height: 92vh; border-radius: 20px 20px 0 0; }
  .legal-table { font-size: 12px; }
}
.subscription-summary{margin-top:10px;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:var(--surface-soft,#faf8ff);font-size:13px;color:var(--muted-text);display:flex;gap:8px 16px;flex-wrap:wrap}.subscription-summary:empty{display:none}.subscription-summary strong{color:var(--text)}
.admin-metrics-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:12px;margin-top:18px}.admin-metric-card{padding:16px;border:1px solid var(--border);border-radius:14px;background:linear-gradient(145deg,#fff,#faf8ff);display:flex;flex-direction:column;gap:6px}.admin-metric-card>span{font-size:12px;color:var(--muted-text);font-weight:700;text-transform:uppercase;letter-spacing:.04em}.admin-metric-card>strong{font-size:26px;color:var(--text)}.admin-metric-card>small{font-size:12px;color:var(--muted-text)}.admin-vertical-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin-top:14px}.admin-vertical-card{border:1px solid var(--border);border-radius:14px;padding:16px;background:#fff}.admin-vertical-card h3{margin:0 0 10px}.admin-vertical-card>div{display:flex;justify-content:space-between;gap:16px;padding:7px 0;border-bottom:1px solid var(--border)}.admin-vertical-card>div:last-child{border-bottom:0}@media(max-width:1000px){.admin-metrics-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:640px){.admin-metrics-grid,.admin-vertical-grid{grid-template-columns:1fr}}
.admin-funnel-section{margin-top:16px;padding:18px;border:1px solid var(--border);border-radius:14px;background:#fff}.admin-funnel-section h3{margin:0 0 4px}.admin-funnel-section>p{margin:0 0 14px;color:var(--muted-text);font-size:13px}.admin-funnel-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px}.admin-funnel-grid article{position:relative;padding:13px;border-radius:10px;background:#f8f5ff;display:flex;flex-direction:column;gap:5px}.admin-funnel-grid article:not(:last-child)::after{content:'→';position:absolute;right:-8px;top:50%;z-index:2;color:var(--brand-blue);font-weight:900}.admin-funnel-grid span{font-size:11px;color:var(--muted-text);font-weight:700}.admin-funnel-grid strong{font-size:22px}@media(max-width:800px){.admin-funnel-grid{grid-template-columns:1fr 1fr}.admin-funnel-grid article::after{display:none}}@media(max-width:480px){.admin-funnel-grid{grid-template-columns:1fr}}
.credit-ledger-list{max-height:55vh;overflow:auto;margin:16px 0}.credit-ledger-row{display:grid;grid-template-columns:110px 1fr 70px 80px;gap:10px;padding:11px 4px;border-bottom:1px solid var(--border);font-size:13px}.credit-ledger-amount.positive{color:#087f5b}.credit-ledger-amount.negative{color:#c92a2a}@media(max-width:600px){.credit-ledger-row{grid-template-columns:90px 1fr 55px}.credit-ledger-balance{display:none}}
.credit-ledger-list>h3{margin:18px 0 8px;font-size:15px}.credit-lot-card{display:flex;justify-content:space-between;gap:16px;padding:12px 14px;margin-bottom:8px;border:1px solid #d9cdf7;border-radius:12px;background:#faf8ff;font-size:13px}.credit-lot-card span{color:var(--muted-text)}
.credit-ledger-list>h3{margin:18px 0 8px;font-size:15px}.credit-lot-card{display:flex;justify-content:space-between;gap:16px;padding:12px 14px;margin-bottom:8px;border:1px solid #d9cdf7;border-radius:12px;background:#faf8ff;font-size:13px}.credit-lot-card span{color:var(--muted-text)}
.admin-change-list { display:grid; gap:.75rem; }
.admin-change-item { border:1px solid var(--border-color); border-radius:12px; padding:1rem; background:#fff; display:grid; gap:.35rem; }
.admin-change-item small { color:var(--muted); }
.admin-change-item details { margin-top:.35rem; }
.admin-change-item summary { cursor:pointer; color:var(--primary); font-weight:600; }
.admin-change-item pre { max-height:320px; overflow:auto; padding:.75rem; border-radius:8px; background:#171326; color:#f6f2ff; white-space:pre-wrap; word-break:break-word; font-size:.78rem; }
.admin-control-bar,.admin-filter-bar { display:flex; align-items:flex-end; gap:.75rem; flex-wrap:wrap; padding:.85rem; border:1px solid #d8ccff; border-radius:14px; background:#f8f5ff; box-shadow:0 4px 14px rgba(72,42,130,.06); }
.admin-field { display:grid; gap:.35rem; min-width:210px; margin:0; }
.admin-field span { color:#413957; font-size:.76rem; font-weight:800; letter-spacing:.035em; text-transform:uppercase; }
.admin-field select { min-height:46px; padding:10px 38px 10px 12px; border:2px solid #8d62ef; border-radius:10px; background-color:#fff; color:#211831; font-weight:700; box-shadow:0 2px 8px rgba(83,48,153,.08); cursor:pointer; }
.admin-field select:hover { border-color:#6733d8; background-color:#fcfaff; }
.admin-field select:focus { outline:0; border-color:#6733d8; box-shadow:0 0 0 4px rgba(103,51,216,.14); }
.admin-control-bar .btn,.admin-filter-bar .btn { min-height:46px; margin:0; white-space:nowrap; }
.admin-preview-panel { margin:1.25rem 0 1.75rem; padding:1.1rem; border:1px solid #d9cdf8; border-radius:16px; background:#fbf9ff; }
.admin-preview-panel .brand-header { margin-bottom:1rem; }
.admin-preview-checks { display:flex; flex-wrap:wrap; gap:.5rem; margin:.75rem 0; }
.admin-preview-check { padding:.45rem .7rem; border-radius:999px; font-size:.76rem; font-weight:800; }
.admin-preview-check.ok { background:#e5f8f0; color:#176a50; }
.admin-preview-check.warning { background:#fff0df; color:#9a4d08; }
.admin-preview-columns { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
.admin-preview-columns article { min-width:0; }
.admin-preview-columns pre { min-height:220px; max-height:460px; overflow:auto; white-space:pre-wrap; word-break:break-word; padding:1rem; border-radius:12px; background:#171326; color:#f7f4ff; font-size:.78rem; line-height:1.55; }
.admin-brain-schema { display:grid; grid-template-columns:1.1fr .9fr; gap:1rem; margin:1.2rem 0; }
.admin-brain-schema > div { padding:1rem; border:1px solid #ded6f4; border-radius:14px; background:#fcfbff; }
.admin-brain-schema h2 { margin:0 0 .25rem; font-size:1rem; }
.admin-governance-grid { display:grid; grid-template-columns:1fr 1fr; gap:.65rem; margin-top:.8rem; }
.governance-card { display:flex; gap:.65rem; align-items:flex-start; padding:.7rem; border:1px solid #e6e0f2; border-radius:10px; background:#fff; }
.governance-card > strong { display:grid; place-items:center; width:28px; height:28px; flex:0 0 28px; border-radius:8px; background:#efeaff; color:#5634b8; }
.governance-card b { font-size:.82rem; }
.governance-card p { margin:.18rem 0 0; font-size:.72rem; line-height:1.4; color:#625b72; }
.governance-protected > strong { background:#ffe8ed; color:#a62846; }
.governance-limited > strong { background:#fff0d9; color:#8a5100; }
.governance-operational > strong { background:#e3f3ff; color:#17628c; }
.admin-protections-list { margin:.8rem 0 0; padding-left:1.25rem; }
.admin-protections-list li { margin:.45rem 0; color:#40394f; font-size:.8rem; line-height:1.45; }
.field-governance { display:inline-flex; margin-left:.35rem; padding:.2rem .45rem; border-radius:999px; font-size:.68rem; font-weight:800; vertical-align:middle; }
.field-limited { background:#fff0d9; color:#805000; }
.field-editorial { background:#eee8ff; color:#5734b0; }
.field-operational { background:#e3f3ff; color:#17628c; }
.field-protected { background:#ffe8ed; color:#a62846; }
.scene-selector { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.75rem; max-height:340px; overflow:auto; margin-top:.4rem; padding:.75rem; border:1px solid #d9cff1; border-radius:12px; background:#fbfaff; }
.scene-selector fieldset { min-width:0; margin:0; padding:.65rem; border:1px solid #e5def2; border-radius:10px; background:#fff; }
.scene-selector legend { padding:0 .3rem; color:#352855; font-size:.76rem; font-weight:800; }
.scene-option { display:grid; grid-template-columns:auto 1fr; gap:.15rem .45rem; align-items:center; margin:.35rem 0; padding:.35rem; border-radius:7px; cursor:pointer; }
.scene-option:hover { background:#f5f1ff; }
.scene-option input { grid-row:1 / span 2; width:18px; height:18px; margin:0; }
.scene-option span { font-size:.77rem; font-weight:700; }
.scene-option code { overflow:hidden; text-overflow:ellipsis; color:#746b83; font-size:.65rem; }
@media (max-width:760px) {
  .admin-control-bar,.admin-filter-bar { align-items:stretch; }
  .admin-field { width:100%; min-width:0; }
  .admin-control-bar .btn,.admin-filter-bar .btn { width:100%; }
  .admin-preview-columns,.admin-brain-schema,.admin-governance-grid,.scene-selector { grid-template-columns:1fr; }
}
html.admin-portal #nav-signup,
html.admin-portal #nav-client,
html.admin-portal #nav-admin,
html.admin-portal #view-signup,
html.admin-portal #client,
html.admin-portal #feedback-launcher,
html.admin-portal #view-login .actions span:has(#go-signup) {
  display: none !important;
}

/* Identidade exclusiva do portal administrativo */
.admin-product-label,.admin-login-hero{display:none}
html.admin-portal{--admin-navy:#18132d;--admin-violet:#6c3bf1;--admin-pink:#e83f9f;--admin-soft:#f2edff}
html.admin-portal body{background:radial-gradient(circle at 88% 8%,rgba(108,59,241,.13),transparent 28rem),linear-gradient(145deg,#f8f6fc 0%,#f1edfa 100%)}
html.admin-portal header{border-bottom:1px solid #ddd5ec;background:rgba(255,255,255,.96);box-shadow:0 4px 20px rgba(29,19,53,.05)}
html.admin-portal .admin-product-label{display:flex;align-items:center;gap:10px;margin-left:18px;padding-left:18px;border-left:1px solid #ddd5ec;color:var(--admin-navy)}
html.admin-portal .admin-product-icon{display:grid;place-items:center;width:34px;height:34px;border-radius:10px;background:linear-gradient(135deg,var(--admin-violet),var(--admin-pink));color:#fff;font-size:12px;box-shadow:0 6px 16px rgba(108,59,241,.2)}
html.admin-portal .admin-product-label>span:last-child{display:grid;gap:1px}
html.admin-portal .admin-product-label strong{font-size:15px;letter-spacing:-.01em}
html.admin-portal .admin-product-label small{color:#746d82;font-size:10px;text-transform:uppercase;letter-spacing:.08em}
html.admin-portal main.wrap{min-height:calc(100vh - 80px);align-items:flex-start;padding-top:52px}
html.admin-portal #view-login{display:grid;grid-template-columns:minmax(300px,1.1fr) minmax(320px,.9fr);column-gap:48px;row-gap:14px;width:100%;max-width:980px;margin:0 auto;padding:0;overflow:hidden;border:1px solid #ddd5ec;border-radius:26px;background:#fff;box-shadow:0 28px 70px rgba(38,25,67,.12)}
html.admin-portal #view-login.hidden{display:none}
html.admin-portal .admin-login-hero{display:flex;grid-row:1 / span 4;flex-direction:column;justify-content:center;min-height:480px;padding:48px;background:linear-gradient(145deg,#19132f 0%,#2d1f50 72%,#4d2870 100%);color:#fff;position:relative;overflow:hidden}
html.admin-portal .admin-login-hero::after{content:"";position:absolute;width:240px;height:240px;right:-100px;bottom:-110px;border:38px solid rgba(232,63,159,.18);border-radius:50%}
html.admin-portal .admin-login-eyebrow{align-self:flex-start;padding:7px 10px;border:1px solid rgba(255,255,255,.2);border-radius:999px;color:#d9ccff;font-size:10px;font-weight:800;letter-spacing:.12em}
html.admin-portal .admin-login-hero h2{margin:24px 0 14px;color:#fff;font-size:clamp(30px,4vw,46px);line-height:1.02;letter-spacing:-.045em}
html.admin-portal .admin-login-hero p{max-width:430px;margin:0;color:#d9d3e5;font-size:14px;line-height:1.6}
html.admin-portal .admin-login-hero ul{display:grid;gap:10px;margin:28px 0 0;padding:0;list-style:none;color:#f7f4fb;font-size:13px}
html.admin-portal .admin-login-hero li{display:flex;align-items:center;gap:9px}
html.admin-portal .admin-login-hero li::before{content:"✓";display:grid;place-items:center;width:20px;height:20px;border-radius:6px;background:rgba(126,91,238,.28);color:#c7b5ff;font-weight:900}
html.admin-portal #view-login>h1{align-self:end;margin:0;padding:52px 44px 0;color:var(--admin-navy);font-size:28px}
html.admin-portal #view-login>.row,html.admin-portal #view-login>.actions,html.admin-portal #view-login>#auth-msg{margin-left:44px;margin-right:44px}
html.admin-portal #view-login>.row{display:grid;grid-template-columns:1fr;gap:14px}
html.admin-portal #view-login>.actions{align-self:start;display:flex;gap:14px;margin-top:4px}
html.admin-portal #view-login>#auth-msg{align-self:start;min-height:58px;margin-bottom:32px;padding:12px 14px;border-radius:11px;background:#f5f2fb;color:#645b76;font-size:12px;line-height:1.45}
html.admin-portal #view-login>#auth-msg::before{content:"ACESSO RESTRITO";display:block;margin-bottom:3px;color:#5b38bd;font-size:9px;font-weight:900;letter-spacing:.1em}
html.admin-portal #view-login input{min-height:46px}
html.admin-portal #view-login .btn{min-width:112px}
@media(max-width:760px){
  html.admin-portal .admin-product-label{margin-left:8px;padding-left:10px}
  html.admin-portal .admin-product-label small{display:none}
  html.admin-portal main.wrap{padding-top:20px}
  html.admin-portal #view-login{grid-template-columns:1fr;row-gap:12px;border-radius:20px}
  html.admin-portal .admin-login-hero{grid-row:auto;min-height:0;padding:28px 24px}
  html.admin-portal .admin-login-hero h2{margin:16px 0 10px;font-size:30px}
  html.admin-portal .admin-login-hero p{font-size:13px}
  html.admin-portal .admin-login-hero ul{display:none}
  html.admin-portal #view-login>h1{padding:24px 22px 0;font-size:24px}
  html.admin-portal #view-login>.row,html.admin-portal #view-login>.actions,html.admin-portal #view-login>#auth-msg{margin-left:22px;margin-right:22px}
  html.admin-portal #view-login>.actions{align-items:flex-start}
  html.admin-portal #view-login>#auth-msg{margin-bottom:22px}
}
