:root {
  --bg: #f6f5f9;
  --card: #fff;
  --ink: #1d1b22;
  --muted: #6c6878;
  --line: #e7e4ee;
  --soft: #f1eff6;
  --accent: #d62976;
  --accent-2: #962fbf;
  --st-rascunho: #9aa0a6;
  --st-aprovado: #1e9e5a;
  --st-publicado: #4f5bd5;
  --danger: #d93025;
  --warning: #b06000;
  --warning-bg: #fff8e6;
  --success: #1e9e5a;
  --success-bg: #eaf7f0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 20, 60, .06), 0 4px 16px rgba(30, 20, 60, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
h4 { margin: 0; font-size: 14px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--soft); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
.spacer { flex: 1; }

/* ---------- banners ---------- */
.global-banner {
  background: var(--warning-bg); border-bottom: 1px solid #f2db99; color: #7a4200;
  padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13px; z-index: 20; position: relative;
}
.banner-warn {
  background: var(--warning-bg); border: 1px solid #f2db99; color: #7a4200;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; margin-bottom: 12px;
}
.media-warn-banner {
  background: var(--warning-bg); border: 1px solid #f2db99; color: #7a4200;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px; background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); position: relative; }
.logo::after { content: ""; position: absolute; inset: 7px; border: 2px solid #fff; border-radius: 50%; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 7px 11px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 13.5px; }
.nav a:hover { background: var(--soft); color: var(--ink); }
.nav a.active { background: var(--ink); color: #fff; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.pill-badge { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.pill-ok { background: var(--success-bg); color: var(--success); }
.pill-warn { background: var(--warning-bg); color: var(--warning); }
.pill-err { background: #fdf0f0; color: var(--danger); }

main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }
.view-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; justify-content: space-between; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #3a3642; }
.btn.accent { background: var(--accent); border: 0; color: #fff; }
.btn.accent:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 6px 0; font-size: 18px; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; width: 28px; height: 28px; cursor: pointer; color: var(--muted); }
.icon-btn:hover:not(:disabled) { background: var(--soft); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover { color: var(--danger); }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label.danger-label { color: var(--danger); }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); font-weight: 400;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(214, 41, 118, .25); border-color: var(--accent); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: #faf9fd; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1.2fr 1.5fr 1fr; gap: 10px; }
.hint { margin: -4px 0 12px; font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--accent-2); }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }

/* ---------- calendar ---------- */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav h2 { min-width: 200px; text-align: center; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.legend .dot { margin-left: 10px; }
.legend-tip { margin-left: 16px; font-style: italic; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.st-rascunho { background: var(--st-rascunho); }
.dot.st-aprovado { background: var(--st-aprovado); }
.dot.st-publicado { background: var(--st-publicado); }

.cal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-weekdays, .cal-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-weekdays div { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 118px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { background: #fbfafd; }
.cal-cell.out .cal-day span { color: #b8b4c4; }
.cal-cell.over { background: #fdf0f6; outline: 2px dashed var(--accent); outline-offset: -3px; }
.cal-day { display: flex; justify-content: space-between; align-items: center; }
.cal-day span { font-size: 12px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-day span { background: var(--accent); color: #fff; }
.cal-day .add { opacity: 0; border: 0; background: var(--soft); width: 22px; height: 22px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.cal-cell:hover .add { opacity: 1; }
.chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chip {
  display: flex; align-items: center; gap: 5px; padding: 3px 6px; border-radius: 6px;
  font-size: 12px; color: var(--ink); text-decoration: none; background: var(--soft);
  border-left: 3px solid var(--st-rascunho); cursor: grab; min-width: 0;
}
.chip:hover { filter: brightness(.96); }
.chip.st-aprovado { border-left-color: var(--st-aprovado); background: #e9f6ef; }
.chip.st-publicado { border-left-color: var(--st-publicado); background: #eceefc; }
.chip .ic { font-size: 11px; opacity: .7; flex-shrink: 0; }
.chip img { width: 18px; height: 18px; object-fit: cover; border-radius: 3px; flex-shrink: 0; }
.chip .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- list & table ---------- */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input { width: 220px; }
.filters select { width: auto; }
.batch-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 8px; margin-bottom: 12px; }
.batch-bar-info { font-size: 13px; font-weight: 600; color: #3730a3; }
.batch-bar-actions { display: flex; gap: 8px; align-items: center; }
.project-header-row td { background: #f8fafc !important; padding: 8px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.project-header-row:first-child td { border-top: 0; }
.project-header-cell { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.project-title { font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.project-title strong { font-weight: 700; }
.post-select-chk { cursor: pointer; width: 16px; height: 16px; accent-color: var(--accent); }
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfafd; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fcfbfe; }
.table a.theme { color: var(--ink); font-weight: 600; text-decoration: none; }
.table a.theme:hover { text-decoration: underline; }
.table select { width: auto; padding: 4px 8px; font-size: 13px; }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 40px; margin: 0; }

/* ---------- editor ---------- */
.editor-head h2 { margin-right: 4px; }
.dirty { color: var(--accent); font-size: 12px; font-weight: 600; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.prompt-box { position: relative; margin-top: 4px; }
.prompt-box textarea { padding-bottom: 44px; }
.prompt-actions { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }

/* ---------- 3 Variações de Legenda ---------- */
.variations-box { background: #faf9fd; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.variation-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.variation-head { display: flex; justify-content: space-between; align-items: center; }
.variation-eval { font-size: 12px; color: var(--accent-2); background: #f3edf8; padding: 5px 9px; border-radius: 6px; }
.variation-preview { font-size: 13px; line-height: 1.45; white-space: pre-wrap; color: var(--ink); }
.variation-tags { font-size: 12px; color: var(--muted); }

/* ---------- Carrossel Narrativo ---------- */
.slides-head { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.narrative-box { background: #f8f6fc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.slide { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: #fdfcff; }
.slide-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.slide-goal { font-size: 11.5px; color: var(--accent-2); background: #f4ecfb; padding: 3px 8px; border-radius: 6px; margin-bottom: 8px; }
.tag { font-size: 11px; background: var(--ink); color: #fff; padding: 1px 8px; border-radius: 99px; font-weight: 600; }

/* ---------- Mídia Real (Sem gradiente) ---------- */
.media-box { margin-top: 10px; }
.dropzone {
  border: 2px dashed var(--line); border-radius: 10px; padding: 22px 14px; text-align: center;
  display: flex; flex-direction: column; gap: 6px; color: var(--muted); cursor: pointer; transition: .15s; background: #faf9fc;
}
.dropzone strong { color: var(--ink); }
.dropzone:hover, .media-box.over .dropzone { border-color: var(--ink); background: #f1eff6; }
.preview { background: #1a1921; border-radius: 10px; overflow: hidden; display: grid; place-items: center; max-height: 380px; }
.preview img, .preview video { max-width: 100%; max-height: 380px; display: block; object-fit: contain; }
.preview.small { max-height: 120px; border-radius: 6px; }
.preview.small img { max-height: 120px; object-fit: cover; }
.media-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.media-carousel-list { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; padding-right: 4px; }
.media-carousel-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #faf9fd; }
.media-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 12px; }
.media-item-path { font-size: 11px; display: block; margin-top: 4px; word-break: break-all; }
.media-type-bar select { font-size: 13px; padding: 5px 8px; margin-top: 4px; }

/* ---------- Configurações & Provedores ---------- */
.fn-config-block { background: #faf9fd; border: 1px solid var(--line); border-radius: 9px; padding: 12px; margin-bottom: 12px; }
.provider-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.provider-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.provider-test-result { font-size: 12px; margin-top: 8px; padding: 6px 10px; border-radius: 6px; }

/* ---------- Dicas curtas de campo e ajustes de formulário de imagem ---------- */
.field-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.35;
}
.ratio-warn {
  font-size: 11.5px;
  margin-top: 4px;
  margin-bottom: 2px;
  padding: 6px 8px;
  border-radius: 6px;
  line-height: 1.35;
}
#card-image textarea[data-field="image.subject"] {
  min-height: 44px;
  height: 44px;
  resize: vertical;
}
#card-image input[type="text"],
#card-image input:not([type]),
#card-image select {
  padding: 6px 9px;
  font-size: 13.5px;
}
#card-image label {
  margin-bottom: 10px;
}
.scene-opt-selected {
  border-color: var(--accent) !important;
  background: #fdf0f6 !important;
}

/* ---------- Dashboard de Uso ---------- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card { padding: 14px 16px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--ink); }
.progress-bar { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; background: var(--success); }
.progress-fill.warn { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--ink); color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); max-width: 460px;
  animation: in .2s ease-out; font-size: 13px;
}
.toast.ok { background: #16794a; }
.toast.error { background: var(--danger); }
.toast.warn { background: #b06000; }
.toast button { background: rgba(255, 255, 255, .2); border: 0; color: #fff; padding: 5px 10px; border-radius: 6px; cursor: pointer; font: inherit; white-space: nowrap; }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 980px) {
  .editor-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .row3 { grid-template-columns: 1fr; }
  .legend-tip { display: none; }
  .cal-cell { min-height: 84px; }
  .chip { font-size: 11px; padding: 2px 4px; }
  .chip .t { max-width: 80px; }
}

/* ---------- Modal Novo Post com IA ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  overflow-y: auto;
}
.modal-overlay[hidden] {
  display: none !important;
}
.modal-dialog {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.05);
  width: 100%;
  overflow: hidden;
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.btn-obj-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-card, #fff);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.btn-obj-choice:hover {
  border-color: var(--primary, #6366f1);
  background: var(--soft, #f8fafc);
}
.btn-obj-choice.selected {
  border-color: var(--primary, #6366f1);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
  font-weight: 600;
}
.btn-obj-choice .obj-icon {
  font-size: 20px;
  margin-bottom: 4px;
}
.btn-obj-choice .obj-title {
  font-size: 13px;
}

/* ================================================================== LOGIN */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(80vh - 100px);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}
.login-header {
  text-align: center;
  margin-bottom: 24px;
}
.login-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary, #6366f1);
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}
.login-header h2 {
  font-size: 24px;
  margin: 0 0 8px;
  color: var(--fg, #0f172a);
}
.login-header p {
  font-size: 14px;
  color: var(--muted, #64748b);
  margin: 0;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.full-width {
  width: 100%;
}
.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line, #e2e8f0);
  font-size: 12px;
  color: var(--muted, #64748b);
}
