/* =========================================================
   ANALYTICS — Meta Ads
   ========================================================= */
.side-tag {
  font-style: normal; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: rgba(34, 197, 94, .16); color: #22c55e; flex: 0 0 auto !important;
}
.side-link.active .side-tag { background: rgba(255, 255, 255, .22); color: #fff; }
.area-card__media--an { background: radial-gradient(60% 90% at 50% 50%, rgba(34, 197, 94, .25), transparent 70%), linear-gradient(135deg, #07130d, #07090d 70%); color: #4ade80; }
.area-card__media--an svg { filter: drop-shadow(0 0 14px rgba(34, 197, 94, .7)); }
.area-card__media--an::before { background-image: linear-gradient(rgba(74, 222, 128, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(74, 222, 128, .08) 1px, transparent 1px); }

.an { display: flex; flex-direction: column; gap: 16px; }
.an-muted { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.5; }
.an-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.an-head__title { display: flex; gap: 14px; align-items: flex-start; }
.an-head__icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0; display: grid; place-items: center; color: var(--accent);
  background: linear-gradient(160deg, rgba(255, 106, 19, .24), rgba(255, 106, 19, .06)); border: 1px solid rgba(255, 106, 19, .22);
}
.an-head h1 { margin: 0 0 4px; }
.an-head__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.an-head__actions[hidden] { display: none; }

/* Botões e campos */
.an-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: 10px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 700; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s, opacity .15s;
}
.an-btn:hover { border-color: var(--accent); color: var(--accent); }
.an-btn:disabled { opacity: .55; cursor: default; }
.an-btn--primary { background: linear-gradient(135deg, #ff7a26, #ff5a00); border-color: transparent; color: #fff; box-shadow: 0 8px 20px rgba(255, 106, 19, .25); }
.an-btn--primary:hover { color: #fff; filter: brightness(1.06); }
.an-btn--ghost { background: transparent; }
.an-btn--danger { background: transparent; color: var(--error); border-color: rgba(248, 113, 113, .45); }
.an-btn--danger:hover { color: #fff; background: var(--error); border-color: var(--error); }
.an-btn--sm { height: 34px; padding: 0 12px; font-size: 12.5px; }
.an-btn--block { width: 100%; height: 46px; }
.an-select {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--muted); max-width: 100%;
}
.an-select select { background: none; border: none; outline: none; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; max-width: 230px; padding: 0; box-shadow: none; }
.an-select select option { background: var(--panel); color: var(--text); }
.an-mini-select { height: 34px; border-radius: 9px; padding: 0 10px; background: var(--field); border: 1px solid var(--border); color: var(--text); font: inherit; font-size: 12.5px; }
.an-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.an-field input, .an-field textarea, .an-field select {
  width: 100%; padding: 11px 12px; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 500;
  background: var(--field); border: 1px solid var(--border); color: var(--text); outline: none; box-sizing: border-box;
}
.an-field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; resize: vertical; word-break: break-all; }
.an-field input:focus, .an-field textarea:focus, .an-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.an-msg { margin: 0; min-height: 18px; font-size: 13px; font-weight: 600; }
.an-msg.is-ok { color: var(--success); }
.an-msg.is-error { color: var(--error); }

/* Cartões */
.an-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.an-card h2 { margin: 0 0 2px; font-size: 16.5px; font-weight: 800; }
.an-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.an-card__head--wrap { flex-wrap: wrap; align-items: center; }

/* Carregando */
.an-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.an-loading[hidden] { display: none; }
.an-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: an-spin .8s linear infinite; }
@keyframes an-spin { to { transform: rotate(360deg); } }

/* Conectar */
.an-connect { display: grid; grid-template-columns: 1fr; gap: 16px; }
.an-connect[hidden] { display: none; }
.an-steps { list-style: none; counter-reset: an; margin: 0; padding: 0; display: grid; gap: 16px; }
.an-steps li { counter-increment: an; position: relative; padding-left: 42px; display: flex; flex-direction: column; gap: 4px; }
.an-steps li::before {
  content: counter(an); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 800; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(255, 106, 19, .3);
}
.an-steps b { font-size: 14px; }
.an-steps span { font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.an-steps em { font-style: normal; color: var(--text); font-weight: 600; }
.an-steps a { color: var(--accent); font-weight: 600; }
.an-steps code, .an-status code { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--field); border: 1px solid var(--border); color: var(--text); }
.an-connect__form { gap: 12px; }
.an-contas { display: grid; gap: 8px; max-height: 300px; overflow-y: auto; }
.an-contas[hidden] { display: none; }
.an-conta-opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--field); border: 1px solid var(--border);
}
.an-conta-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.an-conta-opt input { margin-top: 3px; accent-color: var(--accent); }
.an-conta-opt span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.an-conta-opt b { font-size: 14px; }
.an-conta-opt small { font-size: 12px; color: var(--muted); word-break: break-word; }
.an-conta-opt em { color: var(--accent); font-style: normal; }

/* Painel */
.an-dash { display: flex; flex-direction: column; gap: 16px; }
.an-dash[hidden] { display: none; }
.an-status { display: flex; flex-direction: column; gap: 8px; }
.an-status__row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.an-status__info { font-size: 13px; color: var(--muted); }
.an-status__note { font-size: 12.5px; color: var(--muted); }
.an-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 99px; }
.an-pill.is-ok { background: rgba(34, 197, 94, .14); color: #22c55e; }
.an-pill.is-ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.an-pill.is-run { background: var(--accent-soft); color: var(--accent); }
.an-pill.is-run .an-spinner { width: 11px; height: 11px; }
.an-pill.is-err { background: rgba(248, 113, 113, .14); color: var(--error); }
.an-alert {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 12px; background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .35);
  color: var(--error); font-size: 13.5px; grid-column: 1 / -1;
}

.an-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.an-toolbar__right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.an-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; max-width: 100%; padding-bottom: 2px; }
.an-chips::-webkit-scrollbar { display: none; }
.an-chips button, .an-seg button {
  flex-shrink: 0; height: 36px; padding: 0 13px; border-radius: 9px; cursor: pointer; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 600; transition: all .15s;
}
.an-chips button:hover, .an-seg button:hover { color: var(--text); border-color: var(--border-strong); }
.an-chips button.is-on, .an-seg button.is-on { background: var(--accent-soft); border-color: rgba(255, 106, 19, .55); color: var(--accent); }
.an-custom { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.an-custom[hidden] { display: none; }
.an-custom input { height: 40px; padding: 0 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); font: inherit; font-size: 13px; color-scheme: inherit; }
html[data-theme="dark"] .an-custom input, html[data-theme="dark"] .an-field input[type="date"] { color-scheme: dark; }
.an-range { margin: -6px 0 0; font-size: 12.5px; color: var(--muted); }
.an-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.an-seg--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.an-seg button { height: 32px; font-size: 12.5px; padding: 0 11px; }

/* KPIs */
.an-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.an-kpi {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
}
.an-kpi__label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.an-kpi__value { font-family: var(--font-head); font-size: 20px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-kpi__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 18px; }
.an-kpi__foot small { font-size: 11.5px; color: var(--muted); }
.an-kpis--main .an-kpi { padding: 16px; position: relative; overflow: hidden; }
.an-kpis--main .an-kpi__value { font-size: 24px; }
.an-kpi--spend { border-color: rgba(255, 106, 19, .4); background: linear-gradient(160deg, rgba(255, 106, 19, .12), var(--panel) 60%); }
.an-kpi--rev { border-color: rgba(34, 197, 94, .35); background: linear-gradient(160deg, rgba(34, 197, 94, .1), var(--panel) 60%); }
.an-kpi--good .an-kpi__value { color: #22c55e; }
.an-kpi--bad .an-kpi__value { color: var(--error); }
.an-delta { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--field); color: var(--muted); }
.an-delta.is-good { background: rgba(34, 197, 94, .14); color: #22c55e; }
.an-delta.is-bad { background: rgba(248, 113, 113, .14); color: var(--error); }
.an-is-loading .an-kpis, .an-is-loading .an-card { opacity: .6; transition: opacity .2s; }

.an-grid2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.an-chart__box { position: relative; height: 280px; }

/* Funil */
.an-funnel { display: flex; flex-direction: column; gap: 12px; }
.an-funnel__top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.an-funnel__top span { color: var(--muted); font-weight: 600; }
.an-funnel__bar { height: 10px; border-radius: 99px; background: var(--field); margin: 6px 0 4px; overflow: hidden; }
.an-funnel__bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ff5a00, #ff9a4d); }
.an-funnel__step small { font-size: 11.5px; color: var(--muted); }

/* Tabela */
.an-table-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.an-search { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 9px; background: var(--field); border: 1px solid var(--border); color: var(--muted); }
.an-search input { background: none; border: none; outline: none; color: var(--text); font: inherit; font-size: 13px; width: 160px; padding: 0; box-shadow: none; }
.an-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.an-check input { accent-color: var(--accent); }
.an-table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.an-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1100px; }
.an-table th, .an-table td { padding: 10px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.an-table th { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--panel); }
.an-table th.is-sort { color: var(--accent); }
.an-table .is-txt { text-align: left; }
.an-table td small { color: var(--muted); font-size: 11px; margin-left: 2px; }
.an-table tbody tr:hover td { background: var(--field); }
.an-table tfoot td { font-weight: 800; border-bottom: none; border-top: 2px solid var(--border-strong); }
.an-table td.is-good { color: #22c55e; font-weight: 700; }
.an-table td.is-bad { color: var(--error); font-weight: 700; }
.an-namecell { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; white-space: normal !important; }
.an-namecell > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.an-namecell b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.an-namecell small { margin: 0 !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--field); }
.an-link { background: none; border: none; padding: 0; cursor: pointer; font: inherit; font-size: 11px; font-weight: 700; color: var(--accent); text-decoration: none; }
.an-st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.an-st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.an-st--ok { color: #22c55e; }
.an-st--off { color: var(--muted); }
.an-st--warn { color: #f59e0b; }
.an-st--err { color: var(--error); }
.an-empty { text-align: center !important; color: var(--muted); padding: 26px 10px !important; }
.an-table-foot { font-size: 12px; }

/* Segmentações */
.an-bars { display: flex; flex-direction: column; gap: 10px; }
.an-bar__top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.an-bar__top span { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-bar__top b { white-space: nowrap; }
.an-bar__top small { color: var(--muted); font-weight: 600; margin-left: 4px; }
.an-bar__track { height: 8px; border-radius: 99px; background: var(--field); margin-top: 5px; overflow: hidden; }
.an-bar__track i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ff5a00, #ff9a4d); }
.an-bars--hours { flex-direction: row; align-items: flex-end; gap: 3px; height: 200px; }
.an-hbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.an-hbar i { width: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #ff9a4d, #ff5a00); }
.an-hbar span { font-size: 9.5px; color: var(--muted); }

/* Receita manual */
.an-rec-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.an-field--wide { grid-column: 1 / -1; }
.an-rec-form .an-btn { grid-column: 1 / -1; height: 44px; }
.an-rec-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.an-rec-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--field); }
.an-rec-list li.an-empty { background: none; }
.an-rec-list li span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.an-rec-list b { font-size: 14px; color: #22c55e; }
.an-rec-list small { font-size: 12px; color: var(--muted); }
.an-icon-btn { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; background: none; border: 1px solid var(--border); color: var(--muted); cursor: pointer; }
.an-icon-btn:hover { color: var(--error); border-color: var(--error); }

/* Vídeo */
.an-video[hidden] { display: none; }
.an-video__bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; }
.an-vbar { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.an-vbar__col { width: 100%; max-width: 70px; height: 140px; display: flex; align-items: flex-end; background: var(--field); border-radius: 8px; overflow: hidden; }
.an-vbar__col i { width: 100%; background: linear-gradient(180deg, #ff9a4d, #ff5a00); }
.an-vbar b { font-size: 13px; }
.an-vbar span { font-size: 11px; color: var(--muted); }
.an-video__foot { grid-column: 1 / -1; }

.an-danger { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 1px dashed var(--border-strong); }
.an-danger p { margin: 0; font-size: 12.5px; color: var(--muted); max-width: 70ch; }

.an-toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); z-index: 700;
  padding: 12px 18px; border-radius: 12px; background: #111827; color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: all .25s; max-width: calc(100vw - 32px);
}
.an-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.an-toast.is-err { background: #7f1d1d; }

@media (min-width: 640px) {
  .an-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .an-kpis--main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .an-rec-form { grid-template-columns: 1fr 1fr 2fr; }
  .an-field--wide { grid-column: auto; }
  .an-rec-form .an-field--wide:last-of-type { grid-column: 1 / -2; }
  .an-rec-form .an-btn { grid-column: auto; }
}
@media (min-width: 1024px) {
  .an-connect { grid-template-columns: 1.2fr 1fr; align-items: start; }
  .an-kpis--main { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .an-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .an-grid2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .an-grid2--even { grid-template-columns: 1fr 1fr; }
  .an-chart__box { height: 320px; }
  .an-toast { bottom: 32px; }
  #screen-analytics .wrap { max-width: 1480px; }
}
@media (min-width: 1380px) {
  .an-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 639px) {
  .an-kpis--main .an-kpi:first-child { grid-column: 1 / -1; }
  .an-video__bars { grid-template-columns: repeat(3, 1fr); }
  .an-search input { width: 120px; }
  .an-select select { max-width: 170px; }
}

/* ---------- Ajustes ---------- */
.an-btn[hidden], .an-msg[hidden] { display: none; }
.an-conta-opt input { width: auto; flex: 0 0 auto; height: auto; padding: 0; box-shadow: none; }
.an-check { white-space: nowrap; }
.an-chart .an-card__head { flex-wrap: wrap; }
.an-chart__vazio { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
@media (min-width: 1380px) { .an-kpis.an-kpis--main { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 639px) { .an-kpis--main .an-kpi__value { font-size: 20px; } }
