/* ============================================================
   Tramalytic — style.css (base do design system)
   Identidade: verde-limão (#c1ff72) como cor de marca + grafite
   nas ações; estrutura limpa (sidebar branca, cards suaves,
   badges pastel, tipografia Poppins).
   ============================================================ */

:root {
  /* Marca — verde-limão */
  --lime: #c1ff72;          /* cor de marca: bloco da logo, CTAs, chips */
  --lime-strong: #b2f255;   /* hover sobre superfícies limão */
  --lime-deep: #79bd2c;     /* traços de gráfico / acentos legíveis */
  --lime-ink: #5a8511;      /* texto/ícone "limão" legível sobre claro */
  --lime-100: #eefcd7;      /* tint de fundo suave */
  --lime-50: #f6ffe9;

  /* Ação primária — grafite */
  --primary: #1b1e2c;       /* botões, nav ativa, ênfase (tinta) */
  --primary-dark: #0f111c;  /* hover */
  --primary-100: #edeef2;   /* tint neutro p/ soft buttons, badges, ícones */
  --pink: #e353dd;
  --pink-100: #fdedfc;
  --teal: #09BD3C;
  --teal-100: #e2f8f1;
  --orange: #fd7e14;
  --orange-100: #ffeee8;
  --red: #FC2E53;
  --red-100: #fdeaef;
  --blue: #4eb8f0;
  --blue-100: #e8f6fd;
  --purple: #9c6bf5;
  --purple-100: #f2ebfe;
  --gold: #f6d374;
  --gold-strong: #eec24f;

  /* Escala de cinza — gráficos que pedem paleta neutra (ex.: admin) */
  --chart-gray-900: #1b1e2c;
  --chart-gray-500: #6b7086;
  --chart-gray-track: #dcdee8;

  /* Neutros */
  --body-bg: #f0f1fa;
  --card-bg: #ffffff;
  --surface: #ffffff;
  --text: #2e3350;
  --text-soft: #555b7d;
  --muted: #8b90a7;
  --border: #e9ebf5;
  --border-soft: #f1f2f9;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(46, 51, 80, 0.06);
  --shadow-lg: 0 10px 30px rgba(46, 51, 80, 0.12);

  --sidebar-w: 250px;
  --topbar-h: 66px;
  --z-topbar: 50;

  --font: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Unbounded", "Poppins", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: white;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
button { font-family: inherit; }

::selection { background: var(--lime-100); color: var(--lime-ink); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d6d9ea; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #c2c6de; }

/* ============================================================
   LAYOUT (shell do app: sidebar + topbar + conteúdo)
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

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

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

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.sidebar-head {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 30px 30px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.sidebar-nav { overflow-y: auto; padding: 14px 14px 28px; flex: 1; }

.nav-cat {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .8;
  margin: 20px 10px 8px;
}
.nav-cat:first-child { margin-top: 6px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; }
.nav-link:hover { background: var(--body-bg); color: var(--primary); }
.nav-link.active { background: var(--lime); color: black; font-weight: 600; box-shadow: inset 2px 0 0 black; }
.nav-link.active svg { color: black; }

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--muted);
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30, 33, 56, .45);
  z-index: 55;
}

/* ---------- Logo (arquivo SVG: assets/img/logo-tramalytic.svg) ----------
   O SVG tem "trama" em branco (feito p/ fundo escuro); por isso a logo
   fica sobre uma plaquinha escura para aparecer por inteiro em fundos claros. */
.logo {
  display: flex;
  align-items: center;
  overflow: hidden;
}
.logo img { height: 80px; width: auto; display: block; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  height: 100%;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
}

.hamburger {
  display: none;
  background: none; border: 0; cursor: pointer;
  color: var(--text-soft); padding: 6px;
}
.hamburger svg { width: 22px; height: 22px; }

.search-box { position: relative; width: 340px; max-width: 38vw; }
.search-box input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 40px 0 16px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:focus { border-color: var(--lime-deep); box-shadow: 0 0 0 3px var(--lime-100); }
.search-box svg {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}

.topbar-title { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.topbar-title .book-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title .book-sub { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tb-scores { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
.tb-score { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.tb-score:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--lime-100); border-radius: 6px; }
.tb-score-ico { display: inline-flex; color: var(--text-soft); }
.tb-score-ico svg { width: 16px; height: 16px; stroke-width: 1.8; }
.tb-score-val { font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap; }
.tb-score-val small { font-size: 10px; color: var(--muted); font-weight: 400; }
.tb-score::after {
  content: attr(data-label);
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 6px 10px; font-size: 11.5px; font-weight: 500; color: var(--text-soft);
  white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,.10);
  opacity: 0; visibility: hidden; transition: opacity .15s ease;
  pointer-events: none; z-index: 60;
}
.tb-score:hover::after, .tb-score:focus-visible::after { opacity: 1; visibility: visible; }

.print-only { display: none; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--text-soft);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--body-bg); color: var(--primary); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .count {
  position: absolute; top: -4px; right: -4px;
  min-width: 17px; height: 17px;
  border-radius: 9px;
  background: var(--lime);
  color: #16182a;
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--card-bg);
}
.icon-btn .dot {
  position: absolute; top: 4px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--lime-deep);
  border: 2px solid var(--card-bg);
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 6px 5px 5px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
  border: 0; background: transparent; font-family: inherit;
}
.user-chip:hover { background: var(--body-bg); }
.user-chip .name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #3a3f5c, #1b1e2c);
  color: #fff; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar.lg { width: 76px; height: 76px; font-size: 26px; border-radius: 22px; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 10px);
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: all .18s ease;
  z-index: 70;
}
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-menu .dd-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.dropdown-menu .dd-head .fw-600 { display: block; font-size: 13.5px; }
.dropdown-menu .dd-head span { font-size: 12px; color: var(--muted); }
.dropdown-menu a, .dropdown-menu button.dd-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 13px; font-weight: 500;
  background: none; border: 0; cursor: pointer; font-family: inherit;
  text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button.dd-item:hover { background: var(--body-bg); color: var(--primary); }
.dropdown-menu svg { width: 16px; height: 16px; }

/* Popover de notificações - só informativo, sem navegação/ação (134ª/
   132ª entradas do canal: itens antigos eram <a> que levavam pra outra
   página, o que a usuária não queria). */
.dropdown-menu-wide { width: 320px; max-height: 380px; overflow-y: auto; }
.dd-notif { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 8px; }
.dd-notif-ico {
  width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.dd-notif-body { min-width: 0; }
.dd-notif-text { font-size: 12.5px; font-weight: 500; color: var(--text); line-height: 1.4; }
.dd-notif-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   CABEÇALHO DE PÁGINA
   ============================================================ */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.breadcrumb {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; margin-top: 7px;
  color: var(--muted);
}
.breadcrumb a { color: var(--primary); font-weight: 500; }
.breadcrumb .sep { font-size: 10px; opacity: .7; }
.breadcrumb .cur { color: var(--text-soft); font-weight: 500; }

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   GRID
   ============================================================ */
.row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 22px; }
.row + .row { margin-top: 22px; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
  color: black;
  letter-spacing: .05em;
}
.card-tools { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.card-tools a { font-weight: 500; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.card-body { padding: 20px 22px; }
.card-body.tight { padding: 12px 14px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border-soft); }
.card-footer { padding: 14px 22px; border-top: 1px solid var(--border-soft); }

/* Botão "Contestar análise" — injetado no footer dos cards (task #22).
   `has-contestar` é marcado no JS só no footer que recebe o botão, então
   os demais footers do app (narr-ritmo-actions etc.) não são afetados. */
.card-footer.has-contestar { display: flex; align-items: center; gap: 10px; }
.card-footer.has-contestar .card-contestar {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 13px;
  border-radius: 8px;
  background: var(--card-bg); border: 1px solid var(--red); color: var(--red);
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .14s, color .14s, border-color .14s;
}
.card-footer.has-contestar .card-contestar svg { width: 13px; height: 13px; }
.card-footer.has-contestar .card-contestar:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* Card de identidade do personagem (69a entrada) — botão fixo no
   card-footer/narr-ritmo-actions, ao lado do de diagnóstico, em vez de
   injectContestarButton (esse card não tem .card-head/.card-title).
   Mesma aparência de .has-contestar, sem margin-left:auto porque aqui ele
   fica lado a lado com o outro botão, não sozinho empurrado pra direita. */
.narr-ritmo-actions .card-contestar {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 13px;
  border-radius: 8px;
  background: var(--card-bg); border: 1px solid var(--red); color: var(--red);
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .14s, color .14s, border-color .14s;
}
.narr-ritmo-actions .card-contestar svg { width: 13px; height: 13px; }
.narr-ritmo-actions .card-contestar:hover { background: var(--red); color: #fff; border-color: var(--red); }
.plan-summary { font-size: 14px; color: var(--muted); font-weight: 400; }

/* Contestação de análise — modal (tipos selecionáveis + nota) */
.contestar-tipos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.contestar-tipo {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  cursor: pointer; user-select: none;
  transition: border-color .13s, background .13s, box-shadow .13s;
}
.contestar-tipo:hover { border-color: var(--primary); }
.contestar-tipo.sel { border-color: var(--primary); background: var(--primary-100); box-shadow: 0 0 0 3px var(--primary-100); }
.contestar-tipo input { position: absolute; opacity: 0; pointer-events: none; }
.contestar-tipo .ct-radio {
  width: 16px; height: 16px; flex-shrink: 0;
  border-radius: 50%; border: 1.5px solid var(--text-soft);
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .13s, background .13s;
}
.contestar-tipo.sel .ct-radio { border-color: var(--primary); }
.contestar-tipo.sel .ct-radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.contestar-tipo .ct-label { font-size: 13px; font-weight: 500; color: var(--text); }
.contestar-note {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 16px; padding: 11px 14px; border-radius: 10px;
  background: var(--body-bg); border: 1px solid var(--border);
  font-size: 12.5px; line-height: 1.55; color: var(--text-soft);
}
.contestar-note svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; color: var(--primary); }

/* ---------- Stat cards (cards de métrica com ícone) ---------- */
.stat-card { display: flex; align-items: center; gap: 16px; padding: 22px; }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 25px; height: 25px; }
.tint-primary { background: var(--primary-100); color: var(--primary); }
.tint-lime { background: var(--lime-100); color: var(--muted); }
.tint-pink { background: var(--pink-100); color: var(--pink); }
.tint-teal { background: transparent; color: var(--teal); }
.tint-orange { background: var(--orange-100); color: var(--orange); }
.tint-purple { background: var(--purple-100); color: var(--purple); }
.tint-blue { background: var(--blue-100); color: var(--blue); }
.tint-red { background: var(--red-100); color: var(--red); }

.stat-info { min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.stat-extra { display: flex; align-items: center; gap: 8px; margin-top: 2px; }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  border-radius: 6px; padding: 2.5px 7px;
}
.delta.up { background: var(--teal-100); color: var(--teal); }
.delta.down { background: var(--red-100); color: var(--red); }
.delta svg { width: 11px; height: 11px; }

/* ---------- Hero card (gradiente índigo) ---------- */
.hero-card {
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 85% -20%, rgba(193,255,114,.20), transparent 45%),
    radial-gradient(circle at -10% 120%, rgba(193,255,114,.10), transparent 42%),
    linear-gradient(125deg, #232740 0%, #181a2b 55%, #2b3052 100%);
  color: #fff;
  padding: 26px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero-card h2 {
  font-size: 19px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.hero-card h2 svg { width: 21px; height: 21px; }
.hero-card p { font-size: 13px; opacity: .85; margin-top: 7px; max-width: 520px; line-height: 1.65; }

/* Variante compacta do hero-card usada como nota fixa nos Dashboards Editoriais (todas as abas, nao e' saudacao) */
.dash-hero-note { padding: 16px 20px; }
.dash-hero-note h2 { font-size: 15px; }
.dash-hero-note h2 svg { width: 17px; height: 17px; }
.dash-hero-note p { max-width: none; margin-top: 5px; }

/* ---------- Variante do hero-card usada como CTA de upgrade (Pagamento) ---------- */
.upgrade-cta { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.upgrade-cta .uc-text { min-width: 0; }
.upgrade-cta .uc-text h2 { margin-bottom: 8px; }
.upgrade-cta .uc-text p { margin: 0 0 16px; max-width: 300px; }
.upgrade-cta .uc-icon { flex-shrink: 0; opacity: .35; color: var(--lime); }
.upgrade-cta .uc-icon svg { width: 64px; height: 64px; }

.hero-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; margin-top: 22px;
}
.mini-stat {
  background: rgba(255, 255, 255, .96);
  border-radius: 10px;
  padding: 16px 18px;
  color: var(--text);
}
.mini-stat .ms-top { display: flex; align-items: center; justify-content: space-between; }
.mini-stat .ms-ico {
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}
.mini-stat .ms-ico svg { width: 16px; height: 16px; }
.mini-stat .ms-label { font-size: 12.5px; color: var(--text-soft); margin-top: 10px; font-weight: 500; }
.mini-stat .ms-value { font-size: 21px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.mini-stat .ms-value .delta { font-size: 10px; }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 30px; padding: 0 18px;
  border-radius: 9px;
  font-family: inherit; font-size: 12px; font-weight: 400;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }

/* CTA de marca — texto grafite sobre limão (igual à logo) */
.btn-lime { background: var(--lime); color: #16182a; }
.btn-lime:hover:not(:disabled) { background: var(--lime-strong); color: #16182a; }

/* CTA de upgrade — dourado claro */
.btn-gold { background: var(--gold); color: #16182a; }
.btn-gold:hover:not(:disabled) { background: var(--gold-strong); color: #16182a; }

.btn-soft { background: var(--primary-100); color: var(--primary); }
.btn-soft:hover:not(:disabled) { background: var(--primary); color: #fff; }

.btn-soft-lime { background: var(--lime-100); color: var(--lime-ink); }
.btn-soft-lime:hover:not(:disabled) { background: var(--lime); color: #16182a; }

.btn-soft-pink { background: var(--pink-100); color: var(--pink); }
.btn-soft-pink:hover:not(:disabled) { background: var(--pink); color: #fff; }

.btn-soft-teal { background: var(--teal-100); color: var(--teal); }
.btn-soft-teal:hover:not(:disabled) { background: var(--teal); color: #fff; }

.btn-outline { background: var(--card-bg); border-color: var(--border); color: var(--text-soft); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-outline-red { background: var(--card-bg); border-color: var(--red); color: var(--red); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #d92f58; color: #fff; }

.btn-soft-danger { background: var(--red-100); color: var(--red); }
.btn-soft-danger:hover:not(:disabled) { background: var(--red); color: #fff; }

.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--body-bg); color: var(--primary); }

.btn-sm { height: 33px; padding: 0 13px; font-size: 12px; border-radius: 8px; font-weight: 400; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 47px; padding: 0 26px; font-size: 14px; }
.btn-block { width: 100%; }

.btn-icon { width: 33px; height: 33px; padding: 0; border-radius: 8px; }

/* ============================================================
   BADGES / CHIPS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 400;
  padding: 3.5px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-primary { background: var(--primary-100); color: var(--primary); }
.b-lime { background: var(--lime-100); color: var(--lime-deep); }
.b-pink { background: var(--pink-100); color: var(--pink); }
.b-teal { background: var(--teal-100); color: var(--teal); }
.b-orange { background: var(--orange-100); color: #e0734d; }
.b-red { background: var(--red-100); color: var(--red); }
.b-purple { background: var(--purple-100); color: var(--purple); }
.b-blue { background: var(--blue-100); color: #2f9fd8; }
.b-gray { background: #eef0f7; color: var(--muted); }
.b-slate { background: #f5f5f5; color: var(--muted); }

.badge.pulse .bdot { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.chip {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 500;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--body-bg);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.chip.hl { background: var(--lime-100); border-color: transparent; color: var(--lime-ink); font-weight: 600; }

.check-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px 16px; }
.check-opt { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); cursor: pointer; }
.check-opt input { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--lime); }
.field.has-error .check-grid { outline: 1.5px solid var(--red); outline-offset: 6px; border-radius: 8px; }

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-size: 12px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
  background: #f8f9fd;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-soft);
  vertical-align: middle;
}
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fafbfe; }
.table tbody tr:last-child td { border-bottom: 0; }
/* Linha de tabela que abre detalhe ao clique (tickets de suporte) */
.table tbody tr.row-click { cursor: pointer; }
.table tbody tr.row-click:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.table .t-main { font-weight: 600; color: var(--text); }
.table .t-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.table .t-actions { display: flex; gap: 6px; justify-content: flex-end; }

.t-entity { display: flex; align-items: center; gap: 11px; }
.t-entity .avatar { width: 30px; height: 30px; border-radius: 11px; font-size: 13px; }

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
/* Par de campos a 50%/50% dentro de uma linha cheia do form-grid, independente
   de quantas colunas o grid pai tem (ex.: np-modal usa 3) - .field-pair é
   .full (ocupa a linha inteira) e vira um sub-grid de 2 colunas por conta própria. */
.form-grid .field-pair { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.f-group { margin-bottom: 14px; }
.f-group:last-child { margin-bottom: 0; }
.f-label { font-size: 14px; font-weight: 500; color: var(--text); }
.f-label .req { color: var(--red); }
.f-label .opt { color: var(--muted); font-weight: 400; font-size: 11.5px; }

.f-control {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 14px;
  font-family: inherit; font-size: 12px;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  margin-top: 0.5rem;
}
textarea.f-control { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; line-height: 1.6; }
select.f-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b90a7' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}
.f-control::placeholder { color: var(--muted); }
.f-control:focus { border-color: var(--lime); }
.f-control.invalid { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-100); }

.f-hint { font-size: 11.5px; color: var(--muted); }
.f-error { font-size: 11.5px; color: var(--red); font-weight: 500; display: none; }
.field.has-error .f-error { display: block; }
.field.has-error .f-control { border-color: var(--red); }

.input-icon { position: relative; }
.input-icon .f-control { padding-left: 42px; }
.input-icon > svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}

.check-line { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text-soft); cursor: pointer; }
.check-line input { width: 16px; height: 16px; accent-color: var(--lime); cursor: pointer; }

/* ============================================================
   UPLOAD / DROPZONE
   ============================================================ */
.dropzone {
  border: 2px dashed #cdd2ec;
  border-radius: var(--radius);
  background: #fafbff;
  padding: 44px 26px;
  text-align: center;
  cursor: pointer;
  transition: all .18s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--lime-deep); background: var(--lime-100); }
.dz-icon {
  width: 62px; height: 62px; border-radius: 18px;
  background: var(--lime); color: #000;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.dropzone.drag .dz-icon { background: #fff; }
.dz-icon svg { width: 27px; height: 27px; }
.dz-title { font-size: 14.5px; font-weight: 600; }
.dz-title span { color: var(--primary); }
.dz-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.file-row {
  display: flex; align-items: center; gap: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  margin-top: 14px;
  background: var(--card-bg);
}
.file-ico {
  width: 42px; height: 42px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.file-ico svg { width: 19px; height: 19px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

.progress { height: 7px; border-radius: 6px; background: var(--border-soft); overflow: hidden; }
.progress > i {
  display: block; height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--lime-deep), var(--lime));
  transition: width .25s ease;
}
.progress.teal > i { background: linear-gradient(90deg, var(--teal), #4ad6b4); }

/* ============================================================
   TIMELINE (estilo "order tracking")
   ============================================================ */
.timeline { position: relative; padding-left: 4px; }
.tl-item { position: relative; display: flex; gap: 15px; padding-bottom: 24px; }
.tl-item:last-child { padding-bottom: 4px; }
.tl-item::before {
  content: "";
  position: absolute; left: 19px; top: 40px; bottom: 0;
  border-left: 2px dashed var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-ico {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}
.tl-ico svg { width: 17px; height: 17px; }
/* Variações por status do item na timeline (renderProject, dashboards.js:
   itemStatus = aguardando | processando | concluido | erro). */
.tl-ico.aguardando { background: transparent; border: 2px solid #0e74e9; color: #0e74e9; }
.tl-ico.processando { background: #0e74e9; color: white }
.tl-ico.concluido { background: var(--teal); color: white; }
.tl-ico.erro { background: var(--red); color: white; }
.tl-body { flex: 1; min-width: 0; padding-top: 1px; }
.tl-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tl-title { font-size: 14px; font-weight: 500; }
.tl-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tl-model { font-size: 11px; color: var(--muted); opacity: .8; white-space: nowrap; }
.tl-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.tl-desc .fw-600 { color: var(--text-soft); }
.tl-file { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; }
.tl-file svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ============================================================
   LISTAS DE ESTATÍSTICA (estilo "task activity")
   ============================================================ */
.list-stats { display: flex; flex-direction: column; }
.ls-item {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}
.ls-item:last-child { border-bottom: 0; }
.ls-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ls-info { flex: 1; min-width: 0; }
.ls-label { font-size: 13px; font-weight: 600; }
.ls-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.ls-value { text-align: right; }
.ls-value .fw-600 { font-size: 15px; font-weight: 700; display: block; }
.ls-value span { font-size: 11px; color: var(--muted); }

/* ============================================================
   INSIGHTS (pontos fortes / atenção)
   ============================================================ */
.insight-list { display: flex; flex-direction: column; gap: 13px; }
.insight {
  display: flex; gap: 12px;
  font-size: 13px; color: var(--text-soft);
  line-height: 1.6;
}
.insight .in-ico {
  width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.insight .in-ico svg { width: 14px; height: 14px; }
.insight .fw-600 { color: var(--text); }

/* ============================================================
   TOASTS
   ============================================================ */
.toasts {
  position: fixed; top: 18px; right: 18px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
  max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  padding: 13px 16px;
  font-size: 13px;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }
.toast.out { opacity: 0; transform: translateX(20px); transition: all .25s; }
.toast .tico {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.toast .tico svg { width: 14px; height: 14px; }
.toast .fw-600 { display: block; font-size: 13px; }
.toast span { color: var(--muted); font-size: 12px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-back {
  position: fixed; inset: 0;
  background: transparent;
  z-index: 150;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: all .2s;
}
.modal-back.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
  padding: 28px;
  transform: translateY(12px) scale(.98);
  transition: transform .2s;
  text-align: center;
}
.modal-back.show .modal { transform: none; }
.modal .m-ico {
  width: 60px; height: 60px; border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.modal .m-ico svg { width: 27px; height: 27px; }
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--muted); line-height: 1.65; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }

/* Variante de EL.confirm/EL.alert: cabeçalho lime (ícone+título) separado
   do corpo, mesmo padrão visual do .modal-form. Precisou de reestruturação
   de markup (não só CSS) porque o .modal simples não tinha divisão
   cabeçalho/corpo antes disso - tudo ficava direto dentro de .modal,
   padding único, text-align:center. */
.modal.modal-confirm { padding: 0; overflow: hidden; text-align: center; }
.modal-confirm .modal-head {
  display: flex; flex-direction: column; align-items: center;
  gap: 0; padding: 18px 24px 16px; background: var(--lime);
}
.modal-confirm .modal-head .m-ico { margin-bottom: 14px; }
.modal-confirm .modal-head h3 { margin-bottom: 0; color: #000; }
.modal-confirm .modal-content { padding: 22px 24px 24px; }
.modal-actions .btn { flex: 1; }

/* Modal de formulário (uploads / novo projeto): alinhado à esquerda */
.modal.modal-form { max-width: 560px; text-align: left; padding: 0; overflow: hidden; }
.modal.modal-form.modal-wide { max-width: 720px; }
.modal.modal-form.modal-wide.np-modal { max-width: 860px; }
.np-modal .form-grid { grid-template-columns: repeat(3, 1fr); }
.np-modal .check-grid { grid-template-columns: repeat(4, 1fr); }
.np-modal .modal-foot,
.ep-modal .modal-foot { flex-direction: column; align-items: stretch; gap: 12px; }
.np-modal .modal-foot.modal-foot--split { flex-direction: row; align-items: center; justify-content: space-between; }
.modal-foot-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.np-modal .modal-foot-actions,
.ep-modal .modal-foot-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-form .modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; border-bottom: 1px solid var(--border-soft);
  background: var(--lime);
}
.modal-form .modal-head h3 { font-size: 14px; font-weight: 500; margin: 0; color: #000; }
.sec-label { font-size: 14px; font-weight: 500; color: var(--text); margin: 14px 0 10px; }
.modal-form .sec-label { margin: 20px 0 20px; }

/* ---------- Linha rótulo + valor/input (Conta, Segurança) ---------- */
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-row-label { font-size: 14px; font-weight: 500; color: var(--text); flex-shrink: 0; }
.info-row-value { flex: 1; max-width: 360px; }
.info-row-value input.f-control { width: 100%; }
.info-row-static { font-size: 13.5px; color: var(--text-soft); }
.modal-form .m-close {
  width: 32px; height: 32px; flex-shrink: 0;
  border: 2px solid #000; border-radius: 8px;
  background: transparent; color: #000;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.modal-form .m-close:hover { background: #000; color: #fff; }
.modal-form .m-close svg { width: 16px; height: 16px; }
.modal-form .modal-content { padding: 20px 22px; max-height: min(66vh, 660px); overflow-y: auto; }
.modal-form .modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--border-soft);
  background: #fbfbfd;
}
.modal-form .modal-foot.modal-foot--split { justify-content: space-between; align-items: center; }

/* ============================================================
   ESTADOS VAZIOS
   ============================================================ */
.empty { text-align: center; padding: 46px 20px; }
.empty .e-ico {
  width: 70px; height: 70px; border-radius: 22px;
  background: var(--body-bg); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.empty .e-ico svg { width: 30px; height: 30px; }
.empty h4 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.empty p { font-size: 13px; color: var(--muted); max-width: 330px; margin: 0 auto 18px; line-height: 1.65; }

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.fw-600 { font-weight: 600; }
.fw-500 { font-weight: 500; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--border-soft); margin: 18px 0; border: 0; }
.hide { display: none !important; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid var(--lime-100);
  border-top-color: var(--lime-deep);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 1280px) {
  .col-3 { grid-column: span 6; }
  .col-4 { grid-column: span 6; }
  .col-5, .col-7, .col-8, .col-9, .col-6 { grid-column: span 12; }
}

@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .search-box { width: 220px; }
  .user-chip .name { display: none; }
}

@media (max-width: 640px) {
  .content { padding: 16px; }
  .col-3 { grid-column: span 12; }
  .form-grid { grid-template-columns: 1fr; }
  .np-modal .form-grid { grid-template-columns: 1fr; }
  .form-grid .field-pair { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .np-modal .check-grid { grid-template-columns: 1fr; }
  .search-box { display: none; }
  .tb-scores { display: none; }
  .hero-stats { grid-template-columns: 1fr; }
  .page-actions .btn { flex: 1; }
}

/* ============================================================
   IMPRESSÃO (usada pelo "Exportar Relatório em PDF")
   ============================================================ */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .page-actions, .toasts, .sidebar-backdrop, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid var(--border); break-inside: avoid; }
  .row { gap: 14px; }

  /* No PDF: mostra o título da obra (some do topbar junto com o resto) e TODAS as abas */
  .print-only { display: block; }
  [data-rpanel] { display: grid !important; }
  /* Exportação por seção: esconde as demais abas, mostra só a seção escolhida */
  body[data-print-sec] [data-rpanel] { display: none !important; }
  body[data-print-sec="narrativa"] [data-rpanel="narrativa"],
  body[data-print-sec="personagens"] [data-rpanel="personagens"],
  body[data-print-sec="genero"] [data-rpanel="genero"],
  body[data-print-sec="leitores"] [data-rpanel="leitores"],
  body[data-print-sec="acao"] [data-rpanel="acao"] { display: grid !important; }
}
