@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap");

/* ============================================================
   CONSTÂNCIA — Design System
   Habit tracker · crescimento / consistência · SaaS-premium
   Indigo brand · emerald heat · flame streak · light/dark
   ============================================================ */

:root {
  /* ---- Brand (indigo) ---- */
  /* Rampa indigo: o tema claro anda um degrau (500 → 600, 600 → 700) porque o
     indigo-500 dá 4.467:1 sobre branco — reprova o piso AA de 4.5:1 por 0.033.
     Não é preciosismo de número: `--brand` é cor de TEXTO em todo `<a>`, nos
     ícones de título e no fundo do botão primário (com texto branco por cima,
     e contraste é simétrico — o botão media o mesmo 4.467). O indigo-600 sobe
     para 6.288:1 e mantém a identidade: é o degrau que a paleta já usava como
     `--brand-strong`, não uma cor nova. O tema ESCURO não muda: lá o
     `--brand` (#818cf8 sobre #14161d) já dá 6.057:1. */
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-fg: #ffffff;
  --brand-tint: rgba(79, 70, 229, 0.10);
  --brand-tint-strong: rgba(79, 70, 229, 0.18);

  /* ---- Accents ---- */
  --flame: #f59e0b;       /* streak / flame */
  --flame-strong: #f97316;
  --flame-tint: rgba(245, 158, 11, 0.14);

  /* ---- Heat ramp (emerald) — used by heatmap & "done" ---- */
  --heat-0: var(--surface-3);          /* nothing logged */
  --heat-1: #dcfce7;
  --heat-2: #86efac;
  --heat-3: #22c55e;
  --heat-4: #16a34a;
  --heat-5: #15803d;                   /* extra-deep for very strong days */
  --heat-skip: #cbd5e1;                /* pulado / skip */

  /* ---- Mood scale 1..5 (sad → great) ---- */
  --mood-1: #ef4444;
  --mood-2: #f97316;
  --mood-3: #eab308;
  --mood-4: #84cc16;
  --mood-5: #22c55e;

  /* ---- Typography ---- */
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --fs-display: 26px;
  --fs-h1: 20px;
  --fs-h2: 16px;
  --fs-body: 14px;
  --fs-sm: 13px;
  --fs-xs: 12px;
  --fs-micro: 11px;

  /* ---- Radius ---- */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* ---- Spacing / density ---- */
  --content-max: 1080px;
  --gap: 16px;

  /* ---- Status ---- */
  --ok: #16a34a;
  --ok-tint: rgba(22, 163, 74, 0.12);
  --warn: #d97706;
  --warn-tint: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --danger-tint: rgba(220, 38, 38, 0.12);
  --info: #2563eb;
  --info-tint: rgba(37, 99, 235, 0.12);
}

/* ---------- LIGHT ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6fb;
  --bg-grad-1: #f7f8fd;
  --bg-grad-2: #eef0f8;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef0f6;
  --border: #e6e8f0;
  --border-strong: #d4d8e4;
  --text: #14161d;
  --text-2: #424859;
  --muted: #5c6376;
  --faint: #98a0b3;
  --overlay: rgba(18, 22, 34, 0.42);

  --shadow-card: 0 1px 2px rgba(20, 22, 40, 0.05), 0 1px 1px rgba(20, 22, 40, 0.04);
  --shadow-card-hover: 0 8px 24px rgba(40, 38, 90, 0.10), 0 2px 6px rgba(20, 22, 40, 0.06);
  --shadow-pop: 0 16px 48px rgba(20, 18, 60, 0.18), 0 3px 10px rgba(20, 18, 60, 0.08);
  --shadow-brand: 0 6px 18px rgba(99, 102, 241, 0.30);
}

/* ---------- DARK ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --brand: #818cf8;
  --brand-strong: #6366f1;
  /* No escuro a marca é CLARA, então o que vai por cima dela tem que ser
     escuro: texto branco sobre #818cf8 dá 2,98:1 e reprova o piso AA — é o
     botão primário de toda tela ("Entrar", "Salvar", "Novo hábito"). Com o
     texto escuro a mesma dupla sobe para 6,06:1. Só o TEXTO SOBRE a marca
     muda; a marca como cor de texto/ícone sobre o fundo escuro já passava
     (#818cf8 sobre #0b0d13 = 6,06:1) e fica como está. */
  --brand-fg: #14161d;
  --brand-tint: rgba(129, 140, 248, 0.14);
  --brand-tint-strong: rgba(129, 140, 248, 0.24);

  --flame: #fbbf24;
  --flame-strong: #fb923c;
  --flame-tint: rgba(251, 191, 36, 0.16);

  --heat-1: #14532d;
  --heat-2: #166534;
  --heat-3: #22c55e;
  --heat-4: #4ade80;
  --heat-5: #86efac;
  --heat-skip: #3a4252;

  --mood-1: #f87171;
  --mood-2: #fb923c;
  --mood-3: #facc15;
  --mood-4: #a3e635;
  --mood-5: #4ade80;

  --bg: #0b0d13;
  --bg-grad-1: #0e1118;
  --bg-grad-2: #090b10;
  --surface: #14171f;
  --surface-2: #10131a;
  --surface-3: #1c212c;
  --border: #232936;
  --border-strong: #333a4a;
  --text: #e9ebf2;
  --text-2: #b7bdcc;
  --muted: #868fa0;
  --faint: #5f6878;
  --overlay: rgba(3, 5, 9, 0.64);

  --ok: #4ade80;
  --ok-tint: rgba(74, 222, 128, 0.14);
  --warn: #fbbf24;
  --warn-tint: rgba(251, 191, 36, 0.16);
  --danger: #f87171;
  --danger-tint: rgba(248, 113, 113, 0.16);
  --info: #60a5fa;
  --info-tint: rgba(96, 165, 250, 0.16);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow-card-hover: 0 8px 26px rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 18px 54px rgba(0, 0, 0, 0.65);
  --shadow-brand: 0 6px 20px rgba(99, 102, 241, 0.42);
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(130% 90% at 50% -12%, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.006em;
  transition: background-color 0.25s ease, color 0.25s ease;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
::selection { background: var(--brand-tint-strong); }

/* Scrollbars */
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Layout shell
   ============================================================ */
.cn-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Top nav ---------- */
.cn-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.cn-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  padding: 4px 4px 4px 2px;
  border-radius: var(--radius-sm);
  flex: 0 0 auto;
  transition: opacity 0.15s;
}
.cn-brand:hover { color: var(--text); opacity: 0.9; }
.cn-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 11px;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 70%, var(--flame-strong) 165%);
  box-shadow: var(--shadow-brand);
  flex: 0 0 auto;
}
.cn-brand-word {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.03em;
  line-height: 1;
}

.cn-nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.cn-nav-links::-webkit-scrollbar { display: none; }
.cn-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  border: none;
  background: transparent;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.cn-nav-link .bi { font-size: 15px; opacity: 0.85; }
.cn-nav-link:hover { color: var(--text); background: var(--surface-3); }
.cn-nav-link.active {
  color: var(--brand);
  background: var(--brand-tint);
}
.cn-nav-link.active .bi { opacity: 1; }
.cn-nav-spacer { flex: 1 1 auto; }

.cn-icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 17px;
  flex: 0 0 auto;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cn-icon-btn:hover { color: var(--text); background: var(--surface-3); }

/* ---------- Avatar ---------- */
.cn-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.cn-avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.cn-avatar-lg { width: 44px; height: 44px; font-size: 16px; }

/* ---------- User chip (dropdown) ---------- */
.cn-user {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.cn-user:hover { border-color: var(--border-strong); background: var(--surface-2); }
.cn-user-name { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.cn-user.dropdown-toggle::after { margin-left: 0; color: var(--muted); border-top-color: currentColor; }
.cn-level-chip {
  display: inline-flex; align-items: center;
  font-size: var(--fs-micro); font-weight: 800; letter-spacing: 0.02em;
  padding: 2px 7px; border-radius: var(--radius-pill);
  background: var(--flame-tint); color: var(--flame-strong);
  white-space: nowrap;
}

/* ---------- Content container ---------- */
.cn-content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  /* A folga do fim inclui a faixa do botão de feedback (a lib mede e publica em
     `--cfb-fab-faixa`): sem ela, o "Concluir" do último hábito cai debaixo do botão
     e o clique vai para o lugar errado — medido pelo gate em desktop, tablet e
     celular grande. O `padding` que a lib põe no `body` não alcança aqui porque o
     conteúdo rola dentro deste container. */
  padding: 28px 24px calc(64px + var(--cfb-fab-faixa, 4.5rem));
  flex: 1 1 auto;
}

/* ---------- Flash ---------- */
.cn-flash {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 12px 24px 0;
}
.cn-flash:empty { display: none; }
.cn-flash .alert {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

/* ============================================================
   Page header
   ============================================================ */
.cn-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.cn-page-title {
  font-size: var(--fs-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 11px;
}
.cn-page-title .bi { color: var(--brand); font-size: 0.9em; }
.cn-page-sub {
  margin-top: 5px;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* ============================================================
   Cards & surfaces
   ============================================================ */
.cn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.18s;
}
.cn-card-hover:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.cn-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.cn-card-title {
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cn-card-title .bi { color: var(--brand); }
.cn-card-head .cn-card-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.cn-muted { color: var(--muted); }
.cn-faint { color: var(--faint); }

.cn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--gap);
}

/* ---------- Stat block ---------- */
.cn-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.cn-stat-num {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}
.cn-stat-num.brand { color: var(--brand); }
.cn-stat-num.flame { color: var(--flame-strong); }
.cn-stat-num.ok { color: var(--ok); }
.cn-stat-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ============================================================
   Buttons (Bootstrap bridge + custom)
   ============================================================ */
.btn { font-weight: 600; border-radius: var(--radius-sm); }
.btn-brand {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: var(--brand-fg);
  box-shadow: var(--shadow-brand);
  transition: filter 0.15s, transform 0.12s, box-shadow 0.15s;
}
.btn-brand:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-fg); filter: brightness(1.02); }
.btn-brand:active { transform: translateY(1px); }
.btn-soft {
  background: var(--brand-tint);
  border: 1px solid transparent;
  color: var(--brand);
  transition: background 0.15s, color 0.15s;
}
.btn-soft:hover { background: var(--brand-tint-strong); color: var(--brand-strong); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--faint); }

/* ============================================================
   Habit / Today
   ============================================================ */
.cn-habit-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: border-color 0.16s, box-shadow 0.16s, transform 0.16s;
}
.cn-habit-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card-hover); }
.cn-habit-row.done { background: var(--surface-2); }
.cn-habit-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  font-size: 19px;
  color: #fff;
  flex: 0 0 auto;
  background: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.cn-habit-body { flex: 1 1 auto; min-width: 0; }
.cn-habit-name {
  font-size: var(--fs-body);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cn-habit-row.done .cn-habit-name { color: var(--muted); }
.cn-habit-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 3px;
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* Big round check */
.cn-check {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  color: var(--faint);
  font-size: 19px;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.cn-check:hover { border-color: var(--ok); color: var(--ok); transform: scale(1.06); }
.cn-check.done {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  box-shadow: 0 4px 12px var(--ok-tint);
}
.cn-check.done:hover { transform: scale(1.06); filter: brightness(1.04); }

/* Conic completion ring — drive with --pct (0..100) */
.cn-ring {
  --pct: 0;
  --size: 44px;
  --thick: 5px;
  width: var(--size); height: var(--size);
  flex: 0 0 auto;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background:
    conic-gradient(var(--brand) calc(var(--pct) * 1%), var(--surface-3) 0);
  -webkit-mask: none;
}
.cn-ring::before {
  content: "";
  position: relative;
  width: calc(var(--size) - var(--thick) * 2);
  height: calc(var(--size) - var(--thick) * 2);
  border-radius: 50%;
  background: var(--surface);
  grid-area: 1 / 1;
}
.cn-ring > * { grid-area: 1 / 1; z-index: 1; }
.cn-ring-label {
  font-size: var(--fs-micro);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.cn-ring.full { background: conic-gradient(var(--ok) 100%, var(--ok) 0); }

/* Streak / flame */
.cn-streak {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--flame-strong);
  background: var(--flame-tint);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  letter-spacing: -0.01em;
}
.cn-flame {
  color: var(--flame-strong);
  font-size: 14px;
  filter: drop-shadow(0 1px 2px rgba(249, 115, 22, 0.35));
}
.cn-streak.cold { color: var(--muted); background: var(--surface-3); }
.cn-streak.cold .cn-flame { color: var(--faint); filter: none; }

/* Week strip */
.cn-week-strip {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cn-day-dot {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 4px;
  font-size: var(--fs-micro);
  font-weight: 700;
  color: var(--muted);
}
.cn-day-dot > .dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3);
  border: 1.5px solid transparent;
  color: var(--faint);
  font-size: 11px;
  transition: all 0.15s;
}
.cn-day-dot.done > .dot { background: var(--ok); color: #fff; }
.cn-day-dot.skip > .dot { background: repeating-linear-gradient(45deg, var(--heat-skip), var(--heat-skip) 3px, transparent 3px, transparent 6px); color: var(--muted); }
.cn-day-dot.today > .dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.cn-day-dot.today.done > .dot { color: #fff; }
.cn-day-dot.future > .dot { opacity: 0.5; }

/* ============================================================
   Quantity (count/measure habits)
   ============================================================ */
.cn-qty {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.cn-qty-val { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; color: var(--text-2); }
.cn-qty-bar {
  --pct: 0;
  position: relative;
  flex: 1 1 auto;
  height: 8px;
  min-width: 60px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.cn-qty-bar::after {
  content: "";
  position: absolute; inset: 0;
  width: calc(var(--pct) * 1%);
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.cn-qty-bar.full::after { background: linear-gradient(90deg, var(--ok), var(--heat-4)); }

/* ============================================================
   Heatmap (DOM grid — NOT canvas)
   ============================================================ */
.cn-heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
  overflow-x: auto;
  padding: 2px;
}
.cn-heat-cell {
  width: 14px; height: 14px;
  border-radius: 4px;
  background: var(--heat-0);
  box-shadow: inset 0 0 0 1px rgba(20, 22, 40, 0.04);
  cursor: default;
  position: relative;
  transition: transform 0.12s, outline-color 0.12s;
}
[data-theme="dark"] .cn-heat-cell { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05); }
.cn-heat-cell:hover { transform: scale(1.25); outline: 2px solid var(--brand); outline-offset: 1px; z-index: 2; }
.cn-heat-cell[data-nivel="0"]  { background: var(--heat-0); }
.cn-heat-cell[data-nivel="1"]  { background: var(--heat-1); }
.cn-heat-cell[data-nivel="2"]  { background: var(--heat-2); }
.cn-heat-cell[data-nivel="3"]  { background: var(--heat-3); }
.cn-heat-cell[data-nivel="4"]  { background: var(--heat-4); }
.cn-heat-cell[data-nivel="5"]  { background: var(--heat-5); }
.cn-heat-cell[data-nivel="-1"] {
  background: repeating-linear-gradient(45deg, var(--heat-skip), var(--heat-skip) 2px, transparent 2px, transparent 4px);
  background-color: var(--surface-3);
}
/* hover tooltip affordance — page sets title="" or data-tip; we surface it via [data-tip] */
.cn-heat-cell[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--text);
  color: var(--surface);
  font-size: var(--fs-micro);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  box-shadow: var(--shadow-pop);
  z-index: 50;
  pointer-events: none;
}
.cn-heatmap-legend {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-micro); color: var(--muted); font-weight: 600;
  margin-top: 8px;
}
.cn-heatmap-legend .cn-heat-cell { cursor: default; }

/* ============================================================
   Mood
   ============================================================ */
.cn-mood { display: inline-flex; align-items: center; gap: 8px; }
.cn-mood-opt {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px;
  line-height: 1;
  color: var(--faint);
  transition: all 0.16s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.cn-mood-opt[data-humor="1"] { --m: var(--mood-1); }
.cn-mood-opt[data-humor="2"] { --m: var(--mood-2); }
.cn-mood-opt[data-humor="3"] { --m: var(--mood-3); }
.cn-mood-opt[data-humor="4"] { --m: var(--mood-4); }
.cn-mood-opt[data-humor="5"] { --m: var(--mood-5); }
.cn-mood-opt:hover { border-color: var(--m); color: var(--m); transform: translateY(-2px); }
.cn-mood-opt.selected {
  border-color: var(--m);
  background: color-mix(in srgb, var(--m) 16%, var(--surface));
  color: var(--m);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--m) 22%, transparent);
}

/* ============================================================
   Achievements / badges
   ============================================================ */
.cn-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 18px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.cn-badge:not(.locked):hover { box-shadow: var(--shadow-card-hover); transform: translateY(-3px); border-color: var(--border-strong); }
.cn-badge-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  border-radius: 50%;
  font-size: 26px;
  color: #fff;
  background: linear-gradient(135deg, var(--flame), var(--flame-strong));
  box-shadow: 0 6px 16px var(--flame-tint);
}
.cn-badge-name { font-size: var(--fs-sm); font-weight: 700; letter-spacing: -0.01em; }
.cn-badge-desc { font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; }
.cn-badge-xp {
  font-size: var(--fs-micro); font-weight: 800; letter-spacing: 0.04em;
  color: var(--brand);
  background: var(--brand-tint);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}
.cn-badge.locked { opacity: 0.62; filter: saturate(0.25); }
.cn-badge.locked .cn-badge-icon { background: var(--surface-3); color: var(--faint); box-shadow: none; }
.cn-badge.locked .cn-badge-xp { background: var(--surface-3); color: var(--muted); }

/* ============================================================
   Progress / level
   ============================================================ */
.cn-level {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cn-level-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: var(--fs-h2);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  box-shadow: var(--shadow-brand);
  flex: 0 0 auto;
}
.cn-level-bar {
  --pct: 0;
  position: relative;
  flex: 1 1 auto;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.cn-level-bar::after {
  content: "";
  position: absolute; inset: 0;
  width: calc(var(--pct) * 1%);
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand), var(--flame));
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* Pills / chips / tags */
.cn-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.cn-pill.brand { background: var(--brand-tint); color: var(--brand); }
.cn-pill.ok { background: var(--ok-tint); color: var(--ok); }
.cn-pill.warn { background: var(--warn-tint); color: var(--warn); }
.cn-pill.danger { background: var(--danger-tint); color: var(--danger); }
.cn-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  transition: all 0.15s;
}
.cn-chip:hover { border-color: var(--faint); color: var(--text); }
.cn-chip.active { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
.cn-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: #fff;
  background: var(--brand);
  line-height: 1.4;
  white-space: nowrap;
}

/* Category dot */
.cn-cat-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--brand);
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   Empty state
   ============================================================ */
.cn-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 56px 24px;
  color: var(--muted);
}
.cn-empty .cn-empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand);
  font-size: 32px;
}
.cn-empty-title { font-size: var(--fs-h2); font-weight: 700; color: var(--text); }
.cn-empty p { margin: 0; max-width: 360px; line-height: 1.6; }

/* ============================================================
   Data table (chart fallback)
   ============================================================ */
.cn-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.cn-data-table th, .cn-data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.cn-data-table th {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.cn-data-table tbody tr:last-child td { border-bottom: none; }
/* visually hidden but present in DOM (for screen readers / test fallback).
   `display: block` é necessário pra sobrepor o layout automático de <table>:
   width/height explícitos não bastam — o algoritmo de table-layout:auto
   dimensiona pelo conteúdo das linhas mesmo com !important, e o box real
   (do tamanho da tabela paralela inteira) inflava o scrollHeight da página. */
.cn-visually-data {
  display: block !important;
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Toasts
   ============================================================ */
.cn-toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}
.cn-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  animation: cn-toast-in 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.cn-toast.leaving { animation: cn-toast-out 0.2s ease forwards; }
.cn-toast-icon { color: var(--brand); font-size: 17px; flex: 0 0 auto; }
.cn-toast.success .cn-toast-icon { color: var(--ok); }
.cn-toast.warning .cn-toast-icon { color: var(--warn); }
.cn-toast.danger .cn-toast-icon { color: var(--danger); }
.cn-toast-msg { flex: 1 1 auto; min-width: 0; line-height: 1.4; }
.cn-toast-action {
  flex: 0 0 auto;
  border: none;
  background: var(--brand-tint);
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  font-size: var(--fs-xs);
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  transition: background 0.15s;
}
.cn-toast-action:hover { background: var(--brand-tint-strong); }
.cn-toast-close {
  flex: 0 0 auto;
  border: none; background: transparent;
  color: var(--faint); font-size: 16px;
  line-height: 1; padding: 2px;
}
.cn-toast-close:hover { color: var(--text); }
@keyframes cn-toast-in { from { opacity: 0; transform: translateX(16px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes cn-toast-out { to { opacity: 0; transform: translateX(16px) scale(0.97); } }

/* ============================================================
   Auth (public) layout
   ============================================================ */
.cn-auth-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
  gap: 20px;
}
.cn-auth-brand {
  display: inline-flex; align-items: center; gap: 11px;
  font-size: 22px; font-weight: 800; letter-spacing: -0.03em;
  color: var(--text);
}
.cn-auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 30px 30px 28px;
}
.cn-auth-card h1 {
  font-size: var(--fs-h1);
  font-weight: 800;
  margin-bottom: 6px;
}
.cn-auth-card .cn-auth-sub {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-bottom: 22px;
}
.cn-auth-foot {
  margin-top: 20px;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* error pages */
.cn-error-code {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--brand), var(--flame-strong));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============================================================
   Bootstrap bridge (buttons / forms / dropdown / dark)
   ============================================================ */
.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-strong); --bs-btn-hover-border-color: var(--brand-strong);
  --bs-btn-active-bg: var(--brand-strong); --bs-btn-active-border-color: var(--brand-strong);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.bg-primary { background-color: var(--brand) !important; }
.text-primary { color: var(--brand) !important; }
.btn-link { --bs-btn-color: var(--brand); --bs-btn-hover-color: var(--brand-strong); }
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 0.2rem var(--brand-tint);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--muted); }

.dropdown-menu {
  --bs-dropdown-bg: var(--surface);
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-border-radius: var(--radius-sm);
  --bs-dropdown-link-hover-bg: var(--surface-2);
  --bs-dropdown-link-active-bg: var(--brand-tint);
  --bs-dropdown-link-active-color: var(--text);
  --bs-dropdown-link-color: var(--text-2);
  box-shadow: var(--shadow-pop);
  padding: 6px;
}
.dropdown-item { border-radius: var(--radius-sm); display: flex; align-items: center; gap: 9px; font-size: var(--fs-sm); }
.dropdown-item .bi { color: var(--muted); }
.dropdown-header { font-size: var(--fs-xs); color: var(--muted); }
.dropdown-divider { border-color: var(--border); }
.dropdown-logout { margin: 0; }
.dropdown-logout button { width: 100%; text-align: left; border: none; background: transparent; font: inherit; }

[data-bs-theme="dark"] .bg-light { background-color: var(--surface-3) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--text) !important; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .cn-nav { gap: 8px; padding: 0 12px; height: 56px; }
  .cn-nav-link { padding: 8px 10px; }
  .cn-nav-link > span { display: none; }      /* icon-only on mobile */
  .cn-nav-link .bi { font-size: 17px; }
  .cn-user-name { display: none; }
  .cn-level-chip { display: none; }
  .cn-content { padding: 20px 16px calc(56px + var(--cfb-fab-faixa, 4.5rem)); }
  .cn-flash { padding: 10px 16px 0; }
  .cn-page-title { font-size: 22px; }
}
@media (max-width: 420px) {
  .cn-brand-word { display: none; }
}

/* ============================================================
   Contenção de overflow horizontal (responsivo)
   Flex/grid items têm min-width:auto por padrão → não encolhem
   abaixo do conteúdo e estouram a viewport. Liberar o encolhimento
   faz o overflow-x:auto de heatmap/tabelas/faixa engatar de fato.
   ============================================================ */
.cn-card { min-width: 0; }
.cn-grid > * { min-width: 0; }
.cn-heatmap { max-width: 100%; }
.cn-week-strip { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
/* wrapper utilitário para tabelas largas (ex.: leaderboard de streaks) */
.cn-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }

@media (max-width: 720px) {
  /* numa linha estreita, a faixa de 7 dias quebra para a sua própria
     linha rolável em vez de empurrar a linha do hábito para fora */
  .cn-habit-row { flex-wrap: wrap; }
  .cn-week-strip { order: 10; width: 100%; }
  .cn-data-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---- Widget de feedback (lib concilio-feedback) -------------------------- */
/* O widget vem com paleta neutra e lê variáveis `--cfb-*`; aqui elas apontam para
   os tokens do app, então ele acompanha sozinho o tema claro e o escuro. A folha
   da lib vive numa @layer, então este bloco vence mesmo carregando antes. */
:root{
  /* O gate de 19/08/2026 já tinha medido que `--brand` puro ficava em 4.47:1 com
     branco — abaixo do piso AA — e apontou o widget para o tom forte. Em
     29/08/2026 a mesma conta valeu para o app inteiro e a rampa clara andou um
     degrau (ver o bloco de tokens no topo), então `--brand-strong` aqui já é o
     indigo-700: 7,9:1 com branco. */
  --cfb-primaria:var(--brand-strong);
  --cfb-primaria-txt:var(--brand-fg);
  --cfb-fundo:var(--surface);
  --cfb-fundo-2:var(--surface-2);
  --cfb-texto:var(--text);
  --cfb-texto-2:var(--muted);
  --cfb-borda:var(--border);
  --cfb-perigo:var(--danger);
  --cfb-raio:var(--radius-sm);
}

/* No tema escuro o widget fixa o indigo-600, que é ESCURO — então o texto dele
   tem que ser branco, e não pode herdar o `--brand-fg` do tema (que no escuro é
   quase preto, para o botão primário do app, cujo fundo é a marca CLARA). São
   dois fundos opostos com o mesmo nome de token: sem fixar o par aqui, o botão
   "Sugerir melhoria" caía para 2,85:1 em toda tela escura. Com branco: 6,29:1.
   A dívida dos botões primários do próprio app no escuro, que este comentário
   registrava como pendente, foi corrigida em 29/08/2026 no bloco de tokens. */
[data-theme="dark"]{ --cfb-primaria:#4f46e5; --cfb-primaria-txt:#ffffff; }
