:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --border: #e8e8e6;
  --border-strong: #d4d4d0;
  --text: #1a1a18;
  --text-muted: #6b6b66;
  --text-light: #9b9b95;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.08);
  --sidebar-w: 240px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

#app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.sidebar-brand strong {
  display: block;
  font-size: 14px;
}

.sidebar-brand span {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  padding: 14px 12px 4px;
}

.nav-group-label:first-child {
  padding-top: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all .15s;
}

.nav-link:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  color: var(--text-light);
}

.main-shell {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Fundo escurecido atrás do drawer mobile — só existe/aparece em telas
   estreitas (o próprio drawer só é acionável ali, ver .menu-toggle). */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 90;
}

.sidebar-overlay.open {
  display: block;
}

body.no-scroll {
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247,247,245,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
}

/* Marca compacta no header mobile — a marca completa (.sidebar-brand) fica
   fora de tela junto com o resto do drawer fechado, então sem isso o topo
   ficava sem identidade nenhuma em telas estreitas. Reaproveita .brand-icon
   já existente; escondida por padrão (desktop não muda em nada). */
.topbar-brand-icon {
  display: none;
  flex-shrink: 0;
}

.search-wrap {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  z-index: 200;
}

.search-result-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.search-result-item:hover { background: var(--bg); }

.search-result-item small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.content {
  padding: 24px;
  flex: 1;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.page-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-danger {
  color: var(--danger);
  border-color: #fecaca;
}

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

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.metric-card .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.metric-card .value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.metric-card .value small {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.week-nav span {
  font-size: 14px;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filters-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  min-width: 120px;
}

.week-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(220px, 1fr));
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.day-column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.day-column-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.day-column-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.day-column-header span {
  font-size: 12px;
  color: var(--text-muted);
}

.day-column-body {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.day-column-body.drag-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

/* Alternativa mobile ao .week-board (grid de 7 colunas) — escondida por
   padrão; só aparece no breakpoint mobile/tablet, onde o grid de colunas
   passa a ser ilegível. Ver js/pages/week.js. */
.day-selector {
  display: none;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.day-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1 0 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.day-chip-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.day-chip-date {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.day-chip-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0 6px;
  line-height: 1.5;
}

.day-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.day-chip.active .day-chip-date {
  color: var(--accent);
}

.day-content {
  display: none;
}

.day-content-header {
  padding-bottom: 12px;
}

.day-content-header h3 {
  margin: 0;
  font-size: 16px;
}

.day-content-header span {
  font-size: 13px;
  color: var(--text-muted);
}

.day-content-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.story-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: box-shadow .15s, opacity .15s;
  position: relative;
}

.story-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.story-card.dragging {
  opacity: .5;
  cursor: grabbing;
}

.story-card.done {
  opacity: .65;
}

.story-card.done .story-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.story-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.story-order {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.story-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-category { background: var(--bg); color: var(--text-muted); }
.badge-time { background: var(--purple-soft); color: var(--purple); }

.status-ideia { background: #f3f4f6; color: #6b7280; }
.status-planejado { background: var(--accent-soft); color: var(--accent); }
.status-precisa-gravar { background: var(--warning-soft); color: var(--warning); }
.status-gravado { background: #fef3c7; color: #b45309; }
.status-editado { background: var(--purple-soft); color: var(--purple); }
.status-publicado { background: var(--success-soft); color: var(--success); }

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.bruna-alert {
  background: #fdf2f8;
  border: 1px solid #fbcfe8;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 8px;
  font-size: 12px;
}

.bruna-alert strong {
  display: block;
  color: #be185d;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}

.check-item.checked {
  background: var(--success-soft);
  border-color: #bbf7d0;
  color: var(--success);
}

.today-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 800px;
}

.today-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.today-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  min-width: 56px;
}

.today-content { flex: 1; }

.today-content h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.today-content p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.entity-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.entity-card p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.entity-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
}

.data-table tr:last-child td { border-bottom: none; }

.priority-alta { color: var(--danger); font-weight: 600; }
.priority-media { color: var(--warning); font-weight: 600; }
.priority-baixa { color: var(--text-muted); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn .15s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

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

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-group textarea.textarea-lg {
  min-height: 170px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-ai-actions {
  display: flex;
  gap: 6px;
}

.form-section-title {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.checklist-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  grid-column: 1 / -1;
}

.checklist-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.slide-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slide-list.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius);
}

.slide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: box-shadow .15s, opacity .15s;
}

.slide-card:hover {
  box-shadow: var(--shadow);
}

.slide-card.dragging {
  opacity: .5;
}

.slide-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.slide-card-header strong {
  font-size: 13px;
}

.slide-drag-handle {
  cursor: grab;
  color: var(--text-light);
  font-size: 16px;
  line-height: 1;
}

.slide-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.badge-slide-capa { background: var(--accent-soft); color: var(--accent); }
.badge-slide-cta { background: var(--success-soft); color: var(--success); }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 2000;
  animation: slideUp .2s ease;
}

.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
}

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-shell {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .topbar-brand-icon {
    display: grid;
  }

  .topbar {
    padding: 12px 16px;
  }

  .btn {
    min-height: 40px;
  }

  .week-board {
    display: none;
  }

  .day-selector {
    display: flex;
  }

  .day-content {
    display: block;
  }

  .filters-bar select {
    min-height: 40px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 16px;
  }
}

@media (max-width: 600px) {
  .page-header {
    flex-direction: column;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .today-item {
    flex-direction: column;
    gap: 8px;
  }
}

.login-wrap {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-brand strong {
  display: block;
  font-size: 16px;
}

.login-brand span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.login-error {
  font-size: 13px;
  color: var(--danger);
}

.login-success {
  font-size: 13px;
  color: var(--success);
  background: var(--success-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
}

#login-toggle-mode {
  background: transparent;
  border: none;
  color: var(--text-muted);
  text-decoration: underline;
  padding: 4px;
  cursor: pointer;
}

.password-field {
  position: relative;
  display: flex;
}

.password-field input {
  width: 100%;
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--text);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
