/* ── Resumo page (Utmify-style summary dashboard) ───────────────────────── */

.rs-alert {
  border-radius: var(--r);
  margin-bottom: 18px;
  overflow: hidden;
  font-size: 14px;
}
.rs-alert-head {
  padding: 10px 14px;
  font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}
.rs-alert-body { padding: 10px 14px 12px; line-height: 1.6; }
.rs-alert a, .rs-alert button.rs-link {
  color: inherit; text-decoration: underline; background: none; border: none;
  font: inherit; font-weight: 500; cursor: pointer; padding: 0;
}
.rs-alert--warn { background: rgba(255, 159, 67, .12); color: #ff9f43; }
.rs-alert--warn .rs-alert-head { box-shadow: 0 6px 15px -7px rgba(255, 159, 67, .4); }
.rs-alert--err  { background: rgba(234, 84, 85, .12); color: #ea5455; }
.rs-alert--err  .rs-alert-head { box-shadow: 0 6px 15px -7px rgba(234, 84, 85, .4); }
.rs-alert-x { background: none; border: none; color: inherit; font-size: 18px; line-height: 1; opacity: .7; }
.rs-alert-x:hover { opacity: 1; }

/* Filter card */
.rs-card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
}
.rs-filters { margin-bottom: 28px; }
.rs-filters-head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 21px 21px 18px;
  border-bottom: 1px solid var(--border);
}
.rs-title   { font-size: 19.6px; font-weight: 500; color: var(--text-1); margin-bottom: 4px; }
.rs-updated { font-size: 13px; color: var(--text-2); }
.rs-filters-head .btn-primary-u { width: 160px; justify-content: flex-start; }
.rs-filters-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 38px; padding: 18px 21px 6px;
}
.rs-field label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-1); margin-bottom: 6px;
}
.rs-select {
  width: 100%; height: 44px; padding: 0 38px 0 16px;
  border: 1px solid var(--border2); border-radius: 5px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23b9b9c3' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--text-1); font: inherit; font-size: 15px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.rs-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 3px 10px 0 rgba(34, 41, 47, .1); }
.rs-filters-foot {
  display: flex; justify-content: flex-end; gap: 18px; padding: 8px 21px 14px;
}
.rs-more {
  background: none; border: none; color: var(--text-2); font: inherit; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
.rs-more:hover { color: var(--accent); }

/* Section header (collapsible) */
.rs-section { margin-bottom: 28px; }
.rs-section-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
}
.rs-section-head h3 { font-size: 16px; font-weight: 600; color: var(--text-1); margin: 0; }
.rs-section-head svg { width: 16px; height: 16px; color: var(--text-2); transition: transform .2s; }
.rs-section.collapsed .rs-section-head svg { transform: rotate(-90deg); }
.rs-section.collapsed .rs-grid { display: none; }

/* 12-column grid mirroring Utmify's gridstack positions */
.rs-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: 101px;
  gap: 14px 28px;
}
.rs-w {
  grid-column: var(--x) / span var(--w);
  grid-row: var(--y) / span var(--h, 1);
  min-width: 0;
}
.rs-metric {
  height: 100%;
  padding: 21px 21px 14px;
  display: flex; flex-direction: column; justify-content: space-between;
  opacity: 0; animation: rsIn .3s ease forwards;
}
@keyframes rsIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rs-metric-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.rs-metric-label { font-size: 14px; color: var(--text-2); font-weight: 500; line-height: 1.3; }
.rs-metric-value {
  font-size: 24px; font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.rs-metric-value.pos { color: var(--green); }
.rs-metric-value.neg { color: var(--red); }
.rs-metric-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* Info tooltip */
.rs-info {
  position: relative; flex-shrink: 0; width: 18px; height: 18px;
  color: var(--text-3); cursor: help; display: inline-flex;
}
.rs-info svg { width: 18px; height: 18px; }
.rs-info:hover { color: var(--text-1); }
.rs-tip {
  position: absolute; z-index: 50; right: -6px; top: 26px; width: 260px;
  background: #1e1e2d; color: #fff; font-size: 12px; line-height: 1.5; font-weight: 400;
  padding: 10px 12px; border-radius: 6px; white-space: pre-line;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
.rs-info:hover .rs-tip { opacity: 1; visibility: visible; transform: none; }

/* Chart widgets */
.rs-chart {
  height: 100%; padding: 21px; display: flex; flex-direction: column;
  opacity: 0; animation: rsIn .3s ease forwards;
}
.rs-chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rs-chart-title { font-size: 17px; font-weight: 500; color: var(--text-1); }
.rs-chart-body { position: relative; flex: 1; min-height: 0; }
.rs-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 14px; text-align: center;
}
.rs-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.rs-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* Funnel / rate rows */
.rs-rates { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.rs-rate-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.rs-rate-name { font-size: 13px; color: var(--text-2); }
.rs-rate-val  { font-size: 13px; font-weight: 600; color: var(--text-1); }
.rs-bar { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--surface3); overflow: hidden; }
.rs-bar span { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width .6s ease; }

/* Modal */
.rs-modal-back {
  position: fixed; inset: 0; z-index: 3000; background: rgba(34, 41, 47, .5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.rs-modal { width: 100%; max-width: 460px; padding: 24px; }
.rs-modal h3 { font-size: 18px; font-weight: 600; color: var(--text-1); margin-bottom: 6px; }
.rs-modal p  { font-size: 13px; color: var(--text-2); margin-bottom: 18px; line-height: 1.5; }
.rs-input {
  width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--border2); border-radius: 5px;
  background: var(--surface); color: var(--text-1); font: inherit; font-size: 15px;
}
.rs-input:focus { outline: none; border-color: var(--accent); }
.rs-modal .rs-field { margin-bottom: 14px; }
.rs-field-hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.rs-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn-ghost-u {
  background: none; border: 1px solid var(--border2); color: var(--text-2);
  border-radius: 5px; padding: 10px 18px; font-size: 14px;
}
.btn-ghost-u:hover { color: var(--text-1); border-color: var(--text-3); }

/* Responsive collapse of the 12-col grid */
@media (max-width: 1200px) {
  .rs-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-flow: dense; }
  .rs-w { grid-column: auto / span min(var(--w), 6); grid-row: auto / span var(--h, 1); }
  .rs-w--wide { grid-column: auto / span 6; }
}
@media (max-width: 700px) {
  .rs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .rs-w { grid-column: auto / span 1; }
  .rs-w--wide, .rs-w[style*="--h:2"], .rs-w[style*="--h:3"] { grid-column: auto / span 2; }
  .rs-filters-grid { grid-template-columns: 1fr; }
  .rs-filters-head { flex-wrap: wrap; }
}

@media (max-width: 700px) {
  .rs-grid { grid-auto-rows: minmax(96px, auto); }
  .rs-metric { padding: 16px 14px 12px; }
  .rs-metric-label { font-size: 13px; }
  .rs-metric-value { font-size: 18px; white-space: normal; overflow-wrap: anywhere; }
  .rs-chart { min-height: 260px; }
}

/* ── UTMs page ──────────────────────────────────────────────────────────── */
.ut-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 21px; margin-bottom: 18px; }
.ut-status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.ut-stat { padding: 21px; min-height: 120px; }
.ut-stat .rs-metric-value { margin-top: 10px; }
.ut-stat .rs-metric-value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 6px; }
.ut-badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.ut-badge--ok   { background: var(--green-dim);  color: var(--green); }
.ut-badge--warn { background: var(--yellow-dim); color: var(--yellow); }
.ut-badge--off  { background: var(--red-dim);    color: var(--red); }
.ut-steps { display: flex; flex-direction: column; gap: 18px; }
.ut-step { display: flex; gap: 18px; padding: 22px; }
.ut-step-num {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.ut-step-body { flex: 1; min-width: 0; }
.ut-step-body h3 { font-size: 16px; font-weight: 600; color: var(--text-1); margin-bottom: 6px; }
.ut-step-body p  { font-size: 13.5px; color: var(--text-2); line-height: 1.6; margin-bottom: 12px; }
.ut-step-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.ut-step-body p code, .ut-tips code { background: var(--surface2); padding: 1px 6px; border-radius: 4px; color: var(--text-1); }
.ut-code {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 10px 10px 14px;
}
.ut-code > code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; color: var(--text-1); }
.ut-code--block { align-items: flex-start; }
.ut-code pre {
  flex: 1; min-width: 0; max-height: 230px; overflow: auto; margin: 0;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-1); white-space: pre;
}
.ut-copy { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; padding: 8px 14px; background: var(--surface); }
.ut-tips { margin: 12px 0 0 18px; font-size: 12.5px; color: var(--text-2); line-height: 1.7; }
.ut-test { display: flex; gap: 12px; }
.ut-test .rs-input { flex: 1; }
.ut-test-out { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.ut-test-out .btn-primary-u { padding: 7px 16px; text-decoration: none; }
.ut-utm { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-1); }
@media (max-width: 900px) {
  .ut-status-grid { grid-template-columns: 1fr; }
  .ut-head, .ut-test { flex-direction: column; align-items: stretch; }
  .ut-step { padding: 16px; gap: 12px; }
}

/* ── Configurações → Meta Ads: account picker + token guide ─────────────── */
.mt-btn {
  font: inherit; font-size: 12px; padding: 6px 12px; border-radius: 5px; cursor: pointer;
  background: transparent; border: 1px solid var(--border2); color: var(--text-2);
}
.mt-btn:hover:not(:disabled) { color: var(--text-1); border-color: var(--text-3); }
.mt-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mt-btn--primary:hover:not(:disabled) { color: #fff; box-shadow: 0 6px 18px -8px var(--accent); }
.mt-btn:disabled { opacity: .55; cursor: default; }
.mt-picker { padding: 4px 20px 16px; background: var(--surface2); border-top: 1px solid var(--border); }
.mt-picker-msg { padding: 12px 0; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.mt-picker-msg code, .mt-guide code { background: var(--surface3); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.mt-picker-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0 8px; border-bottom: 1px solid var(--border); }
.mt-count { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.mt-list { max-height: 300px; overflow: auto; padding: 4px 0; }
.mt-check { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-1); cursor: pointer; }
.mt-check input { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.mt-check input:disabled { cursor: default; }
.mt-item { padding: 8px 4px; border-radius: 5px; flex-wrap: wrap; }
.mt-item:hover { background: var(--surface); }
.mt-name { font-weight: 500; }
.mt-meta { font-size: 11.5px; color: var(--text-3); margin-left: auto; }
.mt-picker-foot { display: flex; align-items: center; gap: 10px; padding-top: 12px; flex-wrap: wrap; }
.mt-picker-status { font-size: 12px; }
.mt-guide { margin-bottom: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface2); }
.mt-guide summary { cursor: pointer; padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--accent); }
.mt-guide ol { margin: 0; padding: 4px 18px 6px 36px; }
.mt-guide li { font-size: 13px; color: var(--text-1); padding: 6px 0; line-height: 1.55; }
.mt-guide li div { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.mt-guide a { color: var(--accent); }
.mt-guide-note { margin: 4px 14px 12px; padding: 10px 12px; border-radius: 6px; font-size: 12px; line-height: 1.55;
  background: var(--yellow-dim); color: var(--text-1); }

/* ── Campanhas: banned / disabled ad accounts ───────────────────────────── */
.badge-acct-off { background: var(--red-dim); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); white-space: nowrap; }
.badge-acct-off .badge-dot { background: var(--red); }
.acct-off-toggle {
  font: inherit; font-size: 11.5px; padding: 3px 10px; border-radius: 20px; cursor: pointer;
  background: var(--red-dim); color: var(--red); border: none;
}
.acct-off-toggle:hover { text-decoration: underline; }

/* ── Campaigns hub: totals row (Utmify-style) ───────────────────────────── */
tbody tr.tot-row td {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  font-weight: 600; color: var(--text-1);
  border-bottom: 2px solid var(--border2);
}
tbody tr.tot-row:hover td { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
tbody tr.tot-row td.tot-label { white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
#hubAccSel { max-width: 260px; }

/* ── Creatives: open original / "Mais validado" ─────────────────────────── */
.cr-open-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translate(-50%, 6px); z-index: 2;
  background: rgba(0,0,0,.72); color: #fff; font-size: 11.5px; font-weight: 600;
  padding: 5px 12px; border-radius: 20px; white-space: nowrap; opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none;
}
.cr-open:hover .cr-open-hint { opacity: 1; transform: translate(-50%, 0); }
.cr-open:hover img { filter: brightness(.88); }
.cr-top-badge {
  position: absolute; left: 8px; bottom: 8px; z-index: 2;
  background: #ff9f43; color: #fff; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  box-shadow: 0 4px 12px rgba(255,159,67,.45);
}
.cr-open:hover .cr-top-badge { opacity: 0; }
.cr-open-btn {
  flex-shrink: 0; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px; border: 1px solid var(--border2); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.cr-open-btn:hover { color: var(--accent); border-color: var(--accent); }
