:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e0e2e7;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #4338ca;
  --primary-hover: #3730a3;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body.loading > * {
  visibility: hidden;
}

a {
  color: var(--primary);
}

h1,
h2,
h3 {
  margin: 0 0 0.5rem;
}

/* Navegação */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--text);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar-nav a {
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
}

.topbar-nav a:hover {
  color: var(--primary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

#empresa-switch {
  width: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.badge-role {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Cartões / superfícies */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* Formulários */

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row label {
  margin: 0;
  font-weight: 500;
}

/* Botões */

button,
.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

button:hover,
.btn:hover {
  background: var(--primary-hover);
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

/* Mensagens */

#toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  max-width: 22rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast-msg {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.toast-msg.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2rem;
}

/* Quadro (kanban) */

.board-filters {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.board-filters .field {
  min-width: 10rem;
}

/* Dropdown de filtro (ex: resultados a mostrar) */

.dropdown-filter {
  position: relative;
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 20;
  min-width: 15rem;
  max-height: 18rem;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem;
}

.dropdown-panel-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-size: 0.8rem;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.dropdown-panel .checkbox-row {
  padding: 0.3rem 0;
}

.dropdown-panel .checkbox-row label {
  font-weight: 400;
  font-size: 0.85rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.board-column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  min-height: 6rem;
}

.board-column h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.board-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  margin-top: 0.6rem;
  text-decoration: none;
  color: var(--text);
}

.board-card:hover {
  border-color: var(--primary);
}

.board-card .titulo {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 0.25rem;
}

.board-card .meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
}

.board-card img.thumb {
  width: 100%;
  height: 6rem;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 0.4rem;
  display: block;
}

.video-placeholder {
  width: 100%;
  height: 6rem;
  border-radius: 6px;
  margin-bottom: 0.4rem;
  background: #111827;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.72rem;
}

.pill.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
}

@media (max-width: 900px) {
  .board {
    grid-template-columns: 1fr;
  }
}

/* Detalhe de conteúdo */

.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.detail-grid img,
.detail-grid video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.comment {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.comment:last-child {
  border-bottom: none;
}

.comment .autor {
  font-weight: 600;
  font-size: 0.85rem;
}

.comment .data {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.4rem;
}

.comment p {
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
}

@media (max-width: 800px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Tabelas */

.card--table {
  padding: 0;
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  padding-left: 1.25rem;
}

th:last-child,
td:last-child {
  padding-right: 1.25rem;
}

thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

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

tbody tr:hover td {
  background: var(--bg);
}

td.cell-primary {
  font-weight: 600;
  color: var(--text);
}

td.cell-stack {
  white-space: normal;
  vertical-align: top;
}

td.cell-stack > span {
  display: block;
  margin-bottom: 0.4rem;
}

th.col-num,
td.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

th.col-actions,
td.col-actions {
  text-align: right;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  white-space: normal;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.tag strong {
  color: var(--text);
  font-weight: 600;
}

/* Login */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 22rem;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 1.25rem;
}

/* Progresso de upload */

.progress-wrap {
  display: none;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.15s ease;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

/* Calendário de publicações */

.calendar-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.calendar-weekday {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.5rem 0.6rem;
  text-align: center;
}

.calendar-day {
  background: var(--surface);
  min-height: 6.5rem;
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.calendar-day.muted {
  background: var(--bg);
  color: var(--text-muted);
}

.calendar-day.muted .calendar-day-number {
  color: var(--text-muted);
}

.calendar-day.today .calendar-day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
}

.calendar-day-number {
  font-size: 0.85rem;
  font-weight: 600;
}

.calendar-day-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.calendar-chip {
  display: block;
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.calendar-chip:hover {
  border-color: var(--primary);
}

.calendar-chip.warning {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: var(--warning);
}

.calendar-chip.active {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

@media (max-width: 800px) {
  .calendar-day {
    min-height: 4rem;
  }
}

/* Campanhas Meta Ads */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.stat-tile .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-tile .value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.pill.active {
  background: var(--warning-bg, #e6f7ee);
  color: #1a7f4b;
  border-color: #1a7f4b;
}
