/* ==========================================================================
   TubeMetrics — Design System
   Paleta: vermelho YouTube sobre superfícies neutras estilo Stripe Dashboard.
   ========================================================================== */

:root {
  /* Marca */
  --yt-500: #ff0033;
  --yt-600: #e60028;
  --yt-700: #c2001f;
  --yt-400: #ff3d5e;
  --yt-soft: rgba(255, 0, 51, 0.09);
  --yt-soft-2: rgba(255, 0, 51, 0.16);

  /* Superfícies (light) */
  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef1;
  --border: #e4e6ea;
  --border-strong: #d3d7dd;

  /* Texto */
  --text: #10131a;
  --text-2: #4d5563;
  --text-3: #79808f;
  --text-inv: #ffffff;

  /* Semântica */
  --pos: #16875a;
  --pos-soft: rgba(22, 135, 90, 0.11);
  --neg: #c02a37;
  --neg-soft: rgba(192, 42, 55, 0.11);
  --warn: #a8690b;
  --warn-soft: rgba(168, 105, 11, 0.13);
  --info: #3a5ccc;
  --info-soft: rgba(58, 92, 204, 0.11);

  /* Séries de gráfico */
  --s1: #ff0033;
  --s2: #6f4bd8;
  --s3: #1a9e8f;
  --s4: #e08b16;
  --s5: #3a76d8;
  --s6: #c2418e;

  /* Elevação */
  --sh-1: 0 1px 2px rgba(16, 19, 26, 0.05), 0 1px 3px rgba(16, 19, 26, 0.04);
  --sh-2: 0 2px 4px rgba(16, 19, 26, 0.04), 0 8px 20px -6px rgba(16, 19, 26, 0.10);
  --sh-3: 0 10px 40px -12px rgba(16, 19, 26, 0.24);
  --ring: 0 0 0 3px rgba(255, 0, 51, 0.16);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --nav-w: 244px;
  --top-h: 60px;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0a0c10;
  --bg-elevated: #14171d;
  --surface: #14171d;
  --surface-2: #1b1f27;
  --surface-3: #232830;
  --border: #262b34;
  --border-strong: #343a45;

  --text: #f2f4f7;
  --text-2: #a4adbb;
  --text-3: #737d8c;

  --yt-soft: rgba(255, 0, 51, 0.14);
  --yt-soft-2: rgba(255, 0, 51, 0.24);

  --pos: #35c98a;
  --pos-soft: rgba(53, 201, 138, 0.14);
  --neg: #ff6b7a;
  --neg-soft: rgba(255, 107, 122, 0.14);
  --warn: #e8a33d;
  --warn-soft: rgba(232, 163, 61, 0.14);
  --info: #6f96f5;
  --info-soft: rgba(111, 150, 245, 0.14);

  --s1: #ff2e56;
  --s2: #9b7bf0;
  --s3: #35c1b0;
  --s4: #e8a33d;
  --s5: #6f96f5;
  --s6: #e56bb0;

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 12px 28px -10px rgba(0, 0, 0, 0.6);
  --sh-3: 0 16px 48px -12px rgba(0, 0, 0, 0.7);
}

/* ---------------------------------------------------------------- reset -- */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

::selection { background: var(--yt-soft-2); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* Números sempre alinhados — métrica é tabela, não prosa. */
.num, .metric-value, td.n, th.n, .tabular { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- scroll -- */

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid var(--bg);
}
*::-webkit-scrollbar-track { background: transparent; }

/* ========================================================== primitivos == */

/* Ícones inline: nunca encolhem num flex e têm tamanho por contexto. */
.ico-svg { flex-shrink: 0; }

/*
 * flagBR() é colada dentro de texto (ex.: label da barra lateral), não como
 * item direto de um flex container — sem isso, o reset `svg { display:
 * block }` acima derruba a bandeira pra uma linha própria, embaixo do texto.
 */
.flag-br { display: inline-block; vertical-align: -2px; }
.btn .ico-svg { width: 15px; height: 15px; }
.btn-lg .ico-svg { width: 17px; height: 17px; }
.chip .ico-svg { width: 12px; height: 12px; }
.crumbs .ico-svg { width: 13px; height: 13px; }
.empty .ico .ico-svg { width: 19px; height: 19px; }
.suggest .ico-svg { width: 13px; height: 13px; }
.veil .ico-svg { width: 13px; height: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s, border-color .13s, transform .08s, box-shadow .13s;
  box-shadow: var(--sh-1);
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--yt-500);
  border-color: var(--yt-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(194, 0, 31, .32), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover { background: var(--yt-600); border-color: var(--yt-700); }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; border-radius: var(--r); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

.input {
  height: 36px;
  width: 100%;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-1);
  transition: border-color .13s, box-shadow .13s;
}
.input:focus { outline: none; border-color: var(--yt-400); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-3); }

select.input { cursor: pointer; -webkit-appearance: none; appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
/* Sem isso, um seletor de métrica largo empurra o cabeçalho para fora da página. */
.card-head > * { min-width: 0; max-width: 100%; }
.card-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.chip-pos { background: var(--pos-soft); color: var(--pos); }
.chip-neg { background: var(--neg-soft); color: var(--neg); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-brand { background: var(--yt-soft); color: var(--yt-600); }
[data-theme="dark"] .chip-brand { color: var(--yt-400); }

.label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============================================================== layout == */

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

/* --- sidebar --- */
.nav {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--nav-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  height: var(--top-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-brand strong { font-size: 15px; font-weight: 680; letter-spacing: -0.025em; white-space: nowrap; }

/* Marca em duas cores: "Tube" em vermelho, "Metrics" na cor do texto. */
.brand-mark > i { font-style: normal; color: var(--yt-500); }

.logo-mark {
  width: 26px; height: 19px;
  border-radius: 6px;
  background: var(--yt-500);
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(194, 0, 31, .4);
}
.logo-mark::after {
  content: "";
  width: 0; height: 0;
  border-left: 7px solid #fff;
  border-top: 4.5px solid transparent;
  border-bottom: 4.5px solid transparent;
  margin-left: 2px;
}

.nav-scroll { flex: 1; overflow-y: auto; padding: 14px 10px 20px; }
.nav-group + .nav-group { margin-top: 20px; }
.nav-group > .label { padding: 0 8px 7px; display: block; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 9px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 520;
  cursor: pointer;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--yt-soft); color: var(--yt-600); font-weight: 600; }
[data-theme="dark"] .nav-link.active { color: var(--yt-400); }
.nav-link.active::before {
  content: "";
  position: absolute;
  left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--yt-500);
  border-radius: 0 3px 3px 0;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.nav-link .lock { margin-left: auto; opacity: .45; width: 13px; height: 13px; }
.nav-link.locked { opacity: .62; }

.nav-foot { padding: 12px; border-top: 1px solid var(--border); flex-shrink: 0; }

.plan-box {
  padding: 11px 12px;
  border-radius: var(--r);
  background: linear-gradient(140deg, var(--yt-soft), transparent 70%), var(--surface-2);
  border: 1px solid var(--border);
}
.plan-box .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-box .name { font-size: 13px; font-weight: 650; }
.plan-box .meter { height: 4px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 9px 0 5px; }
.plan-box .meter > i { display: block; height: 100%; background: var(--yt-500); border-radius: 99px; transition: width .3s; }
.plan-box .hint { font-size: 11.5px; color: var(--text-3); }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar .crumbs { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--text-3); min-width: 0; }
.topbar .crumbs b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }

.search-wrap { position: relative; width: 100%; max-width: 340px; }
.search-wrap > svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-3); pointer-events: none;
}
.search-wrap .input { padding-left: 32px; }

.page { padding: 24px 22px 64px; max-width: 1360px; width: 100%; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 23px; font-weight: 680; letter-spacing: -0.028em; }
.page-head p { color: var(--text-2); margin-top: 5px; font-size: 13.5px; max-width: 72ch; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; }

.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 15.5px; font-weight: 650; letter-spacing: -0.018em; }
.section-head p { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

/* ---------------------------------------------------------------- grid -- */

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

/* ========================================================== componentes = */

/* --- KPI --- */
.kpi { padding: 15px 16px 14px; position: relative; overflow: hidden; }
.kpi .head { display: flex; align-items: center; gap: 7px; color: var(--text-3); }
.kpi .head svg { width: 14px; height: 14px; }
.kpi .head span { font-size: 12.5px; font-weight: 550; letter-spacing: -0.005em; }
.kpi .metric-value {
  font-size: 26px;
  font-weight: 660;
  letter-spacing: -0.032em;
  margin-top: 9px;
  line-height: 1.15;
}
.kpi .foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.kpi .foot small { color: var(--text-3); font-size: 11.5px; }
.kpi .spark { position: absolute; right: 0; bottom: 0; width: 40%; height: 46px; opacity: .5; pointer-events: none; }

/* --- tabela --- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left;
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0;
}
table.tbl th.n, table.tbl td.n { text-align: right; }
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { color: var(--text); }
table.tbl th .sort-ind { opacity: .45; margin-left: 3px; font-size: 9px; }
table.tbl th.sorted .sort-ind { opacity: 1; color: var(--yt-500); }
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr { transition: background .1s; }
table.tbl tbody tr:hover { background: var(--surface-2); }

.rank-badge {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 5px;
  background: var(--surface-3);
  font-size: 11px; font-weight: 660;
  color: var(--text-2);
  flex-shrink: 0;
}
.rank-badge.top { background: var(--yt-500); color: #fff; }

.vid-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.vid-cell .t { font-weight: 550; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vid-cell .m { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.thumb {
  width: 62px; height: 35px;
  border-radius: 5px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
}
.thumb.short { width: 24px; height: 35px; }
.thumb .dur {
  position: absolute; right: 3px; bottom: 3px;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 9px; font-weight: 600;
  padding: 0 3px;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

/* --- barra proporcional dentro de célula --- */
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell .track { width: 54px; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; flex-shrink: 0; }
.bar-cell .track > i { display: block; height: 100%; border-radius: 99px; background: var(--s1); }

/* --- insight --- */
.insight {
  display: flex;
  gap: 12px;
  padding: 15px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  position: relative;
  overflow: hidden;
}
.insight::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--accent, var(--text-3));
}
.insight .ico {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--accent-soft, var(--surface-3));
  color: var(--accent, var(--text-2));
}
.insight .ico svg { width: 15px; height: 15px; }
.insight h4 { font-size: 13.5px; font-weight: 620; letter-spacing: -0.012em; }
.insight p { font-size: 12.8px; color: var(--text-2); margin-top: 4px; line-height: 1.5; }
.insight .ev {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 7px;
  font-variant-numeric: tabular-nums;
}
/* SVG inline sem width/height assume 300×150 — sempre dimensione. */
.insight .ev svg { width: 12px; height: 12px; flex-shrink: 0; }
.insight.pos { --accent: var(--pos); --accent-soft: var(--pos-soft); }
.insight.neg { --accent: var(--neg); --accent-soft: var(--neg-soft); }
.insight.warn { --accent: var(--warn); --accent-soft: var(--warn-soft); }
.insight.info { --accent: var(--info); --accent-soft: var(--info-soft); }
.insight.brand { --accent: var(--yt-500); --accent-soft: var(--yt-soft); }

/* --- score gauge --- */
.score-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.score-dial { position: relative; width: 148px; height: 148px; flex-shrink: 0; }
.score-dial .val {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-dial .val b { font-size: 38px; font-weight: 680; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.score-dial .val span { font-size: 11px; font-weight: 620; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); margin-top: 5px; }

.score-bars { flex: 1; min-width: 240px; display: grid; gap: 13px; }
.score-bars .row .top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; margin-bottom: 5px; }
.score-bars .row .top b { font-weight: 620; font-variant-numeric: tabular-nums; }
.score-bars .row .top span { color: var(--text-2); }
.score-bars .track { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.score-bars .track > i { display: block; height: 100%; border-radius: 99px; transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* --- faixas de ganho --- */
.range-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.range-card {
  padding: 15px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-align: center;
}
.range-card.mid { border-color: var(--yt-500); background: var(--yt-soft); box-shadow: 0 0 0 1px var(--yt-500); }
.range-card .lbl { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.range-card .v { font-size: 21px; font-weight: 660; letter-spacing: -0.03em; margin-top: 7px; font-variant-numeric: tabular-nums; }
.range-card .rpm { font-size: 11.5px; color: var(--text-3); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* --- heatmap --- */
.heat { display: grid; gap: 3px; }
.heat-row { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat-row .rl { font-size: 10.5px; color: var(--text-3); font-weight: 600; text-align: right; padding-right: 4px; }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: var(--surface-3); cursor: default; transition: transform .1s, outline-color .1s; outline: 1.5px solid transparent; min-height: 12px; }
.heat-cell:hover { transform: scale(1.35); outline-color: var(--text); z-index: 2; position: relative; }
.heat-cell.best { outline: 1.5px solid var(--text); }
.heat-scale { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); justify-content: flex-end; margin-top: 10px; }
.heat-scale .sw { display: flex; gap: 2px; }
.heat-scale .sw i { width: 13px; height: 9px; border-radius: 2px; }

/* --- donut legenda --- */
.legend { display: grid; gap: 9px; }
.legend .item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend .dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.legend .vl { font-weight: 620; font-variant-numeric: tabular-nums; }
.legend .pc { color: var(--text-3); font-size: 11.5px; width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

/* --- tabs / segment --- */
.segment {
  display: flex;
  width: max-content;
  max-width: 100%;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  /* Em telas estreitas a barra rola dentro de si em vez de estourar a página. */
  overflow-x: auto;
  scrollbar-width: none;
}
.segment::-webkit-scrollbar { display: none; }
.segment button {
  flex: 0 0 auto;
  height: 27px;
  padding: 0 11px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 560;
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.segment button:hover { color: var(--text); }
.segment button.on { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* --- chart shell --- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-txt { fill: var(--text-3); font-size: 10.5px; font-family: var(--sans); }
.chart .hover-line { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }

.tip {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-3);
  padding: 9px 11px;
  font-size: 12px;
  min-width: 130px;
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-10px);
  transition: opacity .1s;
}
.tip.on { opacity: 1; }
.tip .th { font-size: 11px; font-weight: 620; color: var(--text-3); margin-bottom: 6px; letter-spacing: .01em; }
.tip .tr { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tip .tr + .tr { margin-top: 4px; }
.tip .tr .l { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip .tr .l i { width: 8px; height: 8px; border-radius: 2px; }
.tip .tr b { font-variant-numeric: tabular-nums; font-weight: 620; }

/* --- paywall --- */
.locked-box { position: relative; }
.locked-box .veil {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 22px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(4px);
  border-radius: var(--r-lg);
  z-index: 5;
}
.locked-box .veil h4 { font-size: 14px; font-weight: 620; }
.locked-box .veil p { font-size: 12.5px; color: var(--text-2); max-width: 34ch; }
.locked-box .blurred { filter: blur(3px); opacity: .55; user-select: none; pointer-events: none; }

/* --- avatar --- */
.avatar {
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-weight: 660;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  overflow: hidden;
}

/* --- capa do canal --- */

/**
 * A capa do YouTube tem proporção fixa e é cortada em cada dispositivo. Usamos
 * `object-fit: cover` com altura fixa para evitar um bloco desproporcional em
 * tela larga, e o degradê no rodapé garante contraste do conteúdo que vem logo
 * abaixo, qualquer que seja a imagem.
 */
.ch-banner {
  position: relative;
  height: 150px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-2);
  margin-bottom: 14px;
}
.ch-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-banner::after {
  content: "";
  position: absolute; inset: auto 0 0 0; height: 52%;
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 92%, transparent), transparent);
  pointer-events: none;
}
@media (max-width: 640px) { .ch-banner { height: 96px; } }

/* --- channel header --- */
.ch-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.ch-head .meta { min-width: 0; flex: 1; }
.ch-head h1 { font-size: 24px; font-weight: 680; letter-spacing: -0.03em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ch-head .handle { color: var(--text-3); font-size: 13.5px; margin-top: 3px; }
.ch-head .facts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* --- empty --- */
.empty { text-align: center; padding: 48px 22px; }
.empty .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 13px; color: var(--text-3); }
.empty h3 { font-size: 15px; font-weight: 620; }
.empty p { color: var(--text-3); font-size: 13px; margin-top: 5px; }

/* --- toast --- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  box-shadow: var(--sh-3);
  font-size: 13px;
  animation: toastIn .22s cubic-bezier(.2,.9,.3,1);
  max-width: 330px;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }

/* --- modal --- */
.overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(10, 12, 16, .5);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  animation: pop .2s cubic-bezier(.2,.9,.3,1);
  max-height: 86vh;
  display: flex; flex-direction: column;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal-head { padding: 18px 20px 0; }
.modal-head h3 { font-size: 17px; font-weight: 660; letter-spacing: -0.022em; }
.modal-head p { font-size: 13px; color: var(--text-2); margin-top: 5px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* --- pricing --- */
/* Auto-fit para não precisar mexer no CSS a cada plano novo no catálogo. */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.price-card { padding: 24px; display: flex; flex-direction: column; position: relative; }
.price-card.feat { border-color: var(--yt-500); box-shadow: 0 0 0 1px var(--yt-500), var(--sh-2); }
.price-card .tag {
  position: absolute; top: -10px; left: 24px;
  background: var(--yt-500); color: #fff;
  font-size: 10.5px; font-weight: 680; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px;
}
.price-card h3 { font-size: 17px; font-weight: 660; letter-spacing: -0.02em; }
.price-card .desc { font-size: 12.8px; color: var(--text-2); margin-top: 5px; min-height: 36px; }
.price-card .amt { display: flex; align-items: baseline; gap: 4px; margin: 16px 0 4px; }
.price-card .amt b { font-size: 34px; font-weight: 690; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.price-card .amt span { color: var(--text-3); font-size: 13px; }
.price-card ul { margin: 18px 0 22px; display: grid; gap: 9px; flex: 1; }
.price-card li { display: flex; gap: 9px; font-size: 13px; align-items: flex-start; line-height: 1.45; }
.price-card li svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1.5px; color: var(--pos); }
.price-card li.off { color: var(--text-3); }
.price-card li.off svg { color: var(--text-3); opacity: .55; }

/*
 * Mesmo padrão do `.price-card li` acima (`align-items: flex-start`, não
 * `center`): a frase quebra em duas linhas em cards estreitos, e centralizar
 * verticalmente deixaria o ícone flutuando entre as duas linhas em vez de
 * colado na primeira.
 */
.cancel-note { display: flex; justify-content: center; align-items: flex-start; gap: 6px; text-align: left; line-height: 1.45; }
.cancel-note .ico { display: inline-flex; flex-shrink: 0; margin-top: 1.5px; }
.cancel-note svg { width: 14px; height: 14px; color: var(--pos); }

/* ============================================================ landing == */

.landing { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }

.lp-nav {
  position: sticky; top: 0; z-index: 40;
  height: 62px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
}
.lp-nav .brand { display: flex; align-items: center; gap: 9px; }
.lp-nav .brand strong { font-size: 16px; font-weight: 690; letter-spacing: -0.03em; }

.hero { padding: 74px 26px 56px; text-align: center; position: relative; overflow: hidden; }
.hero::before {
  content: "";
  position: absolute; top: -320px; left: 50%; transform: translateX(-50%);
  width: 900px; height: 620px;
  background: radial-gradient(ellipse at center, var(--yt-soft-2), transparent 66%);
  pointer-events: none;
}
.hero-inner { position: relative; max-width: 800px; margin: 0 auto; }

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  margin-bottom: 22px;
  border: 1px solid var(--yt-500);
  border-radius: 99px;
  font-size: 13px;
  font-weight: 560;
  letter-spacing: -0.005em;
  color: var(--yt-600);
  background: var(--yt-soft);
}
[data-theme="dark"] .hero-badge { color: var(--yt-400); }
.hero h1 {
  font-size: clamp(32px, 5.4vw, 52px);
  font-weight: 700;
  letter-spacing: -0.042em;
  line-height: 1.06;
}
.hero h1 em { font-style: normal; color: var(--yt-500); }
.hero p { font-size: clamp(15px, 1.9vw, 17.5px); color: var(--text-2); margin-top: 18px; line-height: 1.55; }

.hero-search { display: flex; gap: 9px; margin: 30px auto 0; max-width: 540px; }
.hero-search .search-wrap { max-width: none; }
.hero-search .input { height: 46px; border-radius: var(--r); font-size: 15px; padding-left: 38px; box-shadow: var(--sh-2); }
.hero-search .search-wrap > svg { left: 13px; width: 17px; height: 17px; }

.suggest { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.suggest button {
  height: 28px; padding: 0 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 99px;
  font-size: 12.5px; font-weight: 540;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.suggest button:hover { border-color: var(--yt-500); color: var(--yt-600); background: var(--yt-soft); }

/*
 * Os atalhos de canal se revezam sozinhos. A troca é uma pulsação curta —
 * some, encolhe 4% e volta — em vez de um corte seco: o movimento avisa que
 * a lista mudou sem puxar a atenção de quem está lendo o resto da página.
 */
.suggest button.swap { animation: suggest-pulse .5s ease; }

@keyframes suggest-pulse {
  0%   { opacity: 1;   transform: scale(1); }
  45%  { opacity: 0;   transform: scale(.96); }
  100% { opacity: 1;   transform: scale(1); }
}

/* Quem pediu menos animação no sistema não recebe a pulsação. */
@media (prefers-reduced-motion: reduce) {
  .suggest button.swap { animation: none; }
}

.lp-section { padding: 56px 26px; max-width: 1120px; margin: 0 auto; width: 100%; }
.lp-section h2 { font-size: clamp(23px, 3vw, 30px); font-weight: 690; letter-spacing: -0.032em; text-align: center; }
.lp-section > p.lead { text-align: center; color: var(--text-2); margin: 11px auto 0; max-width: 60ch; font-size: 15px; }

.feat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 34px; }
.feat-card { padding: 22px; }
.feat-card .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--yt-soft); color: var(--yt-500); display: grid; place-items: center; }
.feat-card .ico svg { width: 17px; height: 17px; }
.feat-card h3 { font-size: 14.5px; font-weight: 640; margin-top: 14px; letter-spacing: -0.015em; }
.feat-card p { font-size: 13px; color: var(--text-2); margin-top: 6px; line-height: 1.55; }

.lp-foot { border-top: 1px solid var(--border); padding: 26px; text-align: center; color: var(--text-3); font-size: 12.5px; margin-top: auto; }

.no-ai-band {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 13px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 560;
  color: var(--text-2);
  box-shadow: var(--sh-1);
}
.no-ai-band svg { width: 14px; height: 14px; color: var(--yt-500); }

/* ------------------------------------------- barra lateral recolhida -- */

/**
 * Recolher a barra deixa só os ícones (64 px) e devolve o espaço ao conteúdo —
 * útil em tabelas largas como a comparação de canais e o Top 20.
 * Em telas pequenas a barra já vira gaveta, então o estado recolhido é ignorado.
 */
@media (min-width: 901px) {
  body.nav-collapsed { --nav-w: 64px; }
  body.nav-collapsed .nav-brand strong,
  body.nav-collapsed .nav-group > .label,
  body.nav-collapsed .nav-link span,
  body.nav-collapsed .nav-link .lock,
  body.nav-collapsed .plan-box .meter,
  body.nav-collapsed .plan-box .hint,
  body.nav-collapsed .plan-box .row > *:last-child { display: none; }

  body.nav-collapsed .nav-brand { justify-content: center; padding: 0; }
  body.nav-collapsed .nav-scroll { padding: 14px 8px 20px; }
  body.nav-collapsed .nav-link { justify-content: center; padding: 0; }
  body.nav-collapsed .nav-link.active::before { left: -8px; }
  body.nav-collapsed .nav-foot { padding: 10px 8px; }
  body.nav-collapsed .plan-box { padding: 8px; text-align: center; }
  body.nav-collapsed .plan-box .name { font-size: 11px; }
  body.nav-collapsed .plan-box .row { justify-content: center; }
}

.nav-collapse-btn { display: none; }
@media (min-width: 901px) { .nav-collapse-btn { display: inline-flex; } }

/* ========================================================= responsivo == */

.nav-toggle { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .nav { transform: translateX(-100%); transition: transform .22s cubic-bezier(.3,.9,.3,1); box-shadow: var(--sh-3); }
  body.nav-open .nav { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10,12,16,.45); }
  .main { margin-left: 0; }
  .nav-toggle { display: inline-flex; }
  .g3, .price-grid, .feat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page { padding: 20px 16px 60px; }
  .topbar { padding: 0 14px; }
}

@media (max-width: 640px) {
  .g2, .g3, .g4, .price-grid, .feat-grid, .range-grid { grid-template-columns: minmax(0, 1fr); }
  .heat-row { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 2px; }
  .heat-cell { min-height: 9px; border-radius: 2px; }
  .hero { padding: 48px 18px 40px; }
  .hero-search { flex-direction: column; }
  .lp-section { padding: 40px 18px; }
  .topbar .crumbs { display: none; }
  .kpi .metric-value { font-size: 23px; }
}

@media (max-width: 520px) {
  /* A barra da landing não cabe inteira: "Planos" já existe como seção abaixo. */
  .lp-nav { padding: 0 14px; gap: 8px; }
  .lp-nav [data-nav="#/planos"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* utilidades */
.mt-0 { margin-top: 0; }
.hide { display: none !important; }
.flex { display: flex; }
.ac { align-items: center; }
.jb { justify-content: space-between; }
.g8 { gap: 8px; }
.g12 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-3); }
.txt-2 { color: var(--text-2); }
.fs12 { font-size: 12px; }
.fs13 { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
