/* =====================================================================
   gestao.rich.fitness — CSS compartilhado do painel
   Seções: base · shell (rail/topbar) · cartões e KPIs · tabelas ·
   pills/botões/forms · tabs/switch · mini-gráficos · responsivo
   ===================================================================== */

/* --- base ------------------------------------------------------------ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 400 14.5px/1.55 var(--font-body);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
:focus-visible {
  outline: 2px solid color-mix(in oklch, var(--brand), transparent 30%);
  outline-offset: 2px;
}
h1, h2, h3 { font-family: var(--font-display); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cap {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.up { color: var(--success); }
.down { color: var(--danger); }

/* --- shell ------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.main { min-width: 0; }
.content {
  padding: 24px 28px 48px;
  display: flex; flex-direction: column; gap: 18px;
  max-width: 1360px;
}

/* rail */
.rail {
  position: sticky; top: 0; height: 100vh;
  background: var(--rail); color: var(--rail-fg);
  display: flex; flex-direction: column;
  padding: 18px 12px 14px;
  z-index: 60;
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
.mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center;
  font: 700 14px var(--font-display); letter-spacing: 0.04em;
}
.rail-brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.rail-brand-txt b { font: 600 15px var(--font-display); letter-spacing: -0.01em; }
.rail-brand-txt i {
  font-style: normal; font-size: 10.5px; color: var(--rail-muted);
  letter-spacing: 0.09em; text-transform: uppercase;
}
.rail-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.rail-group {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--rail-muted);
  padding: 14px 10px 6px;
}
.rail-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--rail-muted); font-size: 13.5px; font-weight: 500;
  letter-spacing: 0.01em;
}
.rail-item svg { flex: 0 0 auto; }
.rail-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--rail-fg); }
.rail-item.active { background: rgba(255, 255, 255, 0.08); color: #fff; }
.rail-item.active svg { color: var(--brand); }
.rail-foot { border-top: 1px solid var(--rail-line); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.rail-user { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.rail-user .ava { background: rgba(255, 255, 255, 0.12); color: var(--rail-fg); }
.rail-user span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.rail-user b { font-size: 13px; font-weight: 600; }
.rail-user i { font-style: normal; font-size: 11px; color: var(--rail-muted); }
.rail-out {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--rail-muted); font-size: 13px;
}
.rail-out:hover { background: rgba(255, 255, 255, 0.05); color: var(--rail-fg); }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 28px;
  background: color-mix(in oklch, var(--surface), transparent 16%);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tb-search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 7px 10px; background: var(--surface); color: var(--muted);
  width: 250px;
}
.tb-search input { border: 0; outline: 0; background: none; font: inherit; color: var(--fg); width: 100%; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; color: var(--muted);
  position: relative;
}
.icon-btn:hover { color: var(--fg); }
.icon-btn.has-dot::after {
  content: ""; position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); border: 1.5px solid var(--surface);
}
.nav-toggle { display: none; }
.ava {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--line); color: var(--fg);
  display: grid; place-items: center;
  font: 600 12px var(--font-body); letter-spacing: 0.02em;
}

/* --- novidades (sino) + rodapé versionado ------------------------------ */
.nv-pop {
  position: fixed; top: 62px; right: 20px; z-index: 70;
  width: 372px; max-width: calc(100vw - 32px); max-height: min(72vh, 620px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: 0 14px 44px rgba(20, 18, 12, 0.18);
  overflow: hidden;
}
.nv-pop[hidden] { display: none; }
.nv-pop-h {
  flex: 0 0 auto; display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; padding: 13px 16px 10px; border-bottom: 1px solid var(--line);
}
.nv-pop-h b { font: 600 14px var(--font-display); letter-spacing: -0.01em; }
.nv-pop-h .nv-ver { font-size: 11px; color: var(--muted); }
.nv-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.nv-item { padding: 12px 16px; border-top: 1px solid var(--line); }
.nv-item:first-child { border-top: 0; }
.nv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.nv-mod { font-size: 11px; font-weight: 600; color: var(--muted); }
.nv-ver { font-size: 11px; color: var(--muted); }
.nv-date { font-size: 11px; color: var(--muted); margin-left: auto; }
.nv-chip {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; line-height: 1.5;
}
.nv-chip-novidade { background: var(--brand-soft); color: var(--brand-strong); }
.nv-chip-melhoria { background: color-mix(in oklch, var(--success), transparent 86%); color: var(--success); }
.nv-chip-correcao { background: var(--warn-soft); color: var(--warn); }
.nv-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; margin: 3px 0 0; }
.nv-notes { list-style: none; margin: 6px 0 0; padding: 0; }
.nv-notes li { position: relative; padding-left: 13px; margin: 3px 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.nv-notes li::before { content: "·"; position: absolute; left: 4px; color: var(--brand); font-weight: 700; }

.app-foot { margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--line); }
.app-foot-inner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.app-foot-inner strong { font-weight: 600; color: var(--fg); }
.app-foot-inner time { font-variant-numeric: tabular-nums; }
.app-foot-sep { opacity: 0.45; }
.app-foot-nv {
  margin-left: auto; border: 0; background: none; padding: 0;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--brand-strong);
}
.app-foot-nv:hover { text-decoration: underline; }
@media (max-width: 720px) {
  .nv-pop { top: 58px; right: 12px; left: 12px; width: auto; }
  .app-foot-nv { margin-left: 0; }
}

/* --- cartões e KPIs ---------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px;
  min-width: 0;
}
.card-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card-h h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-h .sub { font-size: 12px; color: var(--muted); }
.card-h .end { margin-left: auto; font-size: 12.5px; color: var(--muted); }
a.more { font-size: 12.5px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
a.more:hover { color: var(--fg); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 18px; }
.kpi .cap { display: block; margin-bottom: 6px; }
.kpi .val {
  font: 500 26px/1.1 var(--font-mono);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.kpi .delta { font-size: 12px; margin-top: 4px; color: var(--muted); }
.kpi .delta b { font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-21 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

/* --- tabelas ------------------------------------------------------------ */
.t-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in oklch, var(--line), transparent 55%); }
td .who { display: flex; flex-direction: column; line-height: 1.25; }
td .who b { font-weight: 600; }
td .who i { font-style: normal; font-size: 12px; color: var(--muted); }

/* --- pills / botões / forms --------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok   { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warn-soft);    color: var(--warn); }
.pill.bad  { background: var(--danger-soft);  color: var(--danger); }
.pill.mut  { background: var(--line);         color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13.5px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--fg);
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: var(--r-sm); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; }
.field input, .field select, .field textarea {
  font: inherit; color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 9px 11px; background: var(--surface); outline: 0;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: color-mix(in oklch, var(--brand), transparent 25%);
}
.field .hint { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .tb-search { width: 260px; }
.toolbar select {
  font: inherit; color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px 10px; background: var(--surface);
}
.toolbar .end { margin-left: auto; }

/* --- tabs / switch -------------------------------------------------------- */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  border: 0; background: none; padding: 9px 14px;
  font-size: 13.5px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--fg); }
[data-panel] { display: none; }
[data-panel].show { display: block; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--border); transition: background 0.15s; pointer-events: none;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
.switch input:checked + i { background: var(--success); }
.switch input:checked + i::after { transform: translateX(16px); }

/* --- mini-gráficos (CSS puro) ---------------------------------------------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 6px; }
.bars b {
  flex: 1; min-width: 6px; border-radius: 4px 4px 0 0;
  background: color-mix(in oklch, var(--brand), white 58%);
}
.bars b.hot { background: var(--brand); }
.bars-x { display: flex; gap: 6px; margin-top: 6px; }
.bars-x span { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); letter-spacing: 0.02em; }

.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 999px; background: var(--brand-strong); }
.meter.thin { height: 5px; }

.frow { display: grid; grid-template-columns: 92px 1fr 74px; gap: 12px; align-items: center; padding: 7px 0; }
.frow .fl { font-size: 12.5px; color: var(--muted); }
.frow .num { font-size: 13px; }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { font-size: 13.5px; font-weight: 600; display: block; }
.row .grow i { font-style: normal; font-size: 12px; color: var(--muted); }
.row .when { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.rank {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  background: var(--line); color: var(--muted);
  display: grid; place-items: center; flex: 0 0 auto;
  font: 600 12px var(--font-mono);
}

.grade { display: flex; gap: 4px; }
.grade span {
  font: 600 10.5px var(--font-mono); padding: 2px 6px;
  border: 1px solid var(--border); border-radius: 5px; color: var(--muted);
}
.grade span.low { border-color: var(--danger); color: var(--danger); }

/* timeline (sequência WhatsApp) */
.tl { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 12px; }
.tl-item .dotcol { display: flex; flex-direction: column; align-items: center; }
.tl-item .dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface); margin-top: 4px;
}
.tl-item.done .dot { background: var(--success); border-color: var(--success); }
.tl-item.now .dot { background: var(--brand); border-color: var(--brand); }
.tl-item .dotcol i { flex: 1; width: 2px; background: var(--line); margin-top: 2px; }
.tl-item:last-child .dotcol i { display: none; }
.tl-item .tl-body { padding-bottom: 16px; }
.tl-item .tl-body b { font-size: 13.5px; font-weight: 600; display: block; }
.tl-item .tl-body i { font-style: normal; font-size: 12px; color: var(--muted); }

.empty {
  border: 1.5px dashed var(--border); border-radius: var(--r-md);
  padding: 22px; text-align: center; color: var(--muted); font-size: 13px;
}

/* --- drawer mobile ------------------------------------------------------------ */
.scrim {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(10, 10, 8, 0.45);
}
body.nav-open .scrim { display: block; }

/* --- responsivo ----------------------------------------------------------------- */
@media (max-width: 1120px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 276px;
    transform: translateX(-100%); transition: transform 0.22s ease;
    height: 100dvh;
  }
  body.nav-open .rail { transform: translateX(0); }
  .nav-toggle { display: grid; }
  .tb-search { display: none; }
  .toolbar .tb-search { display: flex; width: 100%; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 40px; }
  .grid-2, .grid-21 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-3 { grid-template-columns: 1fr; }
  .kpi .val { font-size: 22px; }
  .toolbar .end { margin-left: 0; }
  .card-h { flex-wrap: wrap; row-gap: 4px; }
  /* .row re-flui quando não cabe: o texto ganha a própria linha em vez de
     ficar espremido entre pill e ação (pills longos de formato quebravam
     palavra a palavra em Conteúdo e Insights & Criativos) */
  .row { flex-wrap: wrap; gap: 6px 10px; }
  .row .grow { flex: 1 1 180px; }
  .row .pill { white-space: normal; }
  .row > :last-child { margin-left: auto; }
  table.stackable thead { display: none; }
  table.stackable tr {
    display: block; border: 1px solid var(--border);
    border-radius: var(--r-md); margin-bottom: 10px; padding: 8px 12px;
  }
  table.stackable td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 14px; border: 0; padding: 6px 0; text-align: right;
  }
  table.stackable td::before {
    content: attr(data-th);
    font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted); text-align: left;
  }
  table.stackable tbody tr:hover td { background: none; }
}

/* ---- Avaliações › histórico da conversa (25/07/2026) ---------------- */
.rv-convo-wrap { margin: 4px 0 10px 26px; }
.rv-convo { display: flex; flex-direction: column; gap: 6px; }
.rv-msg { max-width: 78%; padding: 8px 10px; border-radius: 10px; background: var(--line); align-self: flex-start; font-size: .85rem; }
.rv-msg.out { background: var(--success-soft); align-self: flex-end; }
.rv-msg span { display: block; white-space: pre-wrap; word-break: break-word; }
.rv-msg i { display: block; font-style: normal; color: var(--muted); font-size: .7rem; margin-top: 2px; }
.rv-dossie summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.rv-dossie pre { white-space: pre-wrap; word-break: break-word; background: var(--line); border-radius: 10px; padding: 10px; font-size: .8rem; margin-top: 6px; }
.rv-fecho { font-size: .85rem; color: var(--success); }

/* ---- Sugestões › parecer do Analista de Mercado (25/07/2026) -------- */
.sugg-parecer { margin: 8px 0 2px; padding: 8px 10px; border-left: 3px solid var(--line); border-radius: 6px; background: color-mix(in srgb, var(--line) 30%, transparent); }
.sugg-parecer.pend i { color: var(--muted); font-style: normal; font-size: .8rem; }
.sugg-parecer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sugg-parecer-head i { color: var(--muted); font-style: normal; font-size: .78rem; }
