:root {
  --bg0: #0b0f14;
  --bg1: #121820;
  --bg2: #1a222d;
  --line: #2a3441;
  --text: #e8eef5;
  --muted: #8b97a8;
  --brand: #00e08f;
  --brand-dim: #00b873;
  --danger: #ff6b6b;
  --warn: #f0b429;
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Syne", "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(0, 224, 143, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(0, 120, 180, 0.1), transparent 50%),
    var(--bg0);
}

.hidden {
  display: none !important;
}

.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand-lg {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

/* ---- Auth ---- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  background: rgba(18, 24, 32, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  backdrop-filter: blur(8px);
}

.auth-tagline {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  color: var(--bg0);
  background: var(--brand);
  border-color: var(--brand);
}

/* ---- App shell ---- */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: rgba(12, 16, 22, 0.85);
}

.sidebar.collapsed-nav .nav,
.sidebar.onboarding-mode .nav {
  display: none;
}

.sidebar-user {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

.nav a:hover {
  color: var(--text);
  background: var(--bg2);
}

.nav a.active {
  color: var(--bg0);
  background: var(--brand);
}

.content {
  padding: 28px 28px 64px;
  max-width: 1100px;
}

.page-head h1,
.panel h1,
.view h1 {
  font-family: var(--display);
  font-size: 1.75rem;
  margin: 0 0 6px;
  letter-spacing: -0.03em;
}

.lede {
  color: var(--muted);
  margin: 0 0 22px;
  line-height: 1.45;
}

.section-title {
  font-family: var(--display);
  margin: 28px 0 14px;
  font-size: 1.2rem;
}

/* ---- Forms ---- */
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

input,
select,
textarea {
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

input[type="color"] {
  padding: 4px;
  height: 42px;
}

.hint {
  font-size: 0.75rem;
  color: #6b7788;
  font-weight: 400;
}

.hint.center {
  text-align: center;
  margin-top: 8px;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 12px;
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
}

.grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

button,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

button {
  background: var(--brand);
  color: var(--bg0);
}

button:hover {
  background: var(--brand-dim);
}

.btn-secondary,
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-preview {
  width: 100%;
  margin-top: 4px;
  background: transparent;
  color: var(--brand);
  border: 1px solid rgba(0, 224, 143, 0.45);
}

.btn-preview:hover {
  background: rgba(0, 224, 143, 0.12);
}

.lede.compact {
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
  min-height: 1.2em;
}

.success {
  color: var(--brand);
  font-size: 0.85rem;
  margin: 0;
}

.status-line {
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.panel {
  background: rgba(18, 24, 32, 0.8);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

/* ---- Stepper ---- */
.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.step span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--bg1);
  font-size: 0.85rem;
}

.step.active {
  color: var(--text);
}

.step.active span {
  background: var(--brand);
  color: var(--bg0);
  border-color: var(--brand);
}

.step.done span {
  background: var(--brand-dim);
  color: var(--bg0);
  border-color: var(--brand-dim);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--line);
  max-width: 80px;
}

/* ---- Overlay preview (admin only) ---- */
.overlay-preview-wrap {
  margin-bottom: 16px;
}

.overlay-preview-wrap.compact {
  max-width: 360px;
}

.overlay-preview {
  border-radius: 12px;
  padding: 28px 16px;
  background:
    linear-gradient(135deg, #1a2330 0%, #0d1218 100%);
  border: 1px dashed var(--line);
  min-height: 120px;
  display: grid;
  place-items: center;
}

.preview-alert {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-alert strong {
  font-size: 1.25rem;
  color: var(--preview-theme, var(--brand));
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.preview-alert span:last-child {
  color: #fff;
  font-size: 0.95rem;
}

.stage-wrap {
  margin-bottom: 16px;
}

.stage-snap-hint {
  margin-top: 8px;
  max-width: 720px;
}

.overlay-stage {
  position: relative;
  width: 100%;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(0, 224, 143, 0.06), transparent 40%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 23px,
      rgba(255, 255, 255, 0.03) 24px
    ),
    #0d1218;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  /* Escala o mock do QR (e tipografia) como o Browser Source 1920×1080 */
  container-type: inline-size;
  container-name: overlay-stage;
}

.stage-snap-grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  background-image:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(2.5% - 1px),
      rgba(255, 255, 255, 0.08) calc(2.5% - 1px),
      rgba(255, 255, 255, 0.08) 2.5%
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(2.5% - 1px),
      rgba(255, 255, 255, 0.08) calc(2.5% - 1px),
      rgba(255, 255, 255, 0.08) 2.5%
    );
}

.stage-snap-grid.is-on {
  opacity: 1;
}

.stage-guide {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
  background: rgba(0, 224, 143, 0.85);
  box-shadow: 0 0 8px rgba(0, 224, 143, 0.45);
}

.stage-guide.is-on {
  opacity: 1;
}

.stage-guide-v {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
}

.stage-guide-h {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
}

.stage-label {
  position: absolute;
  left: 10px;
  top: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  z-index: 1;
  pointer-events: none;
}

.stage-alert {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translate(-50%, -50%);
  z-index: 4;
  min-width: 140px;
  max-width: 55%;
  padding: 10px 14px;
  text-align: center;
  cursor: grab;
  border: 1px dashed rgba(0, 224, 143, 0.55);
  border-radius: 10px;
  background: rgba(8, 12, 18, 0.55);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.stage-alert:active {
  cursor: grabbing;
}

.stage-alert strong {
  display: block;
  font-size: 0.95rem;
  color: var(--preview-theme, var(--brand));
  line-height: 1.25;
}

.stage-alert > span {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: #fff;
}

/* Espelha .idle-qr do overlay: 140px / 24px / 12px em referência 1920×1080 */
.stage-qr {
  position: absolute;
  right: calc(100% * 24 / 1920);
  bottom: calc(100% * 24 / 1080);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(100cqw * 8 / 1920);
  padding: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.stage-qr-img {
  width: calc(100cqw * 140 / 1920);
  height: calc(100cqw * 140 / 1920);
  border-radius: calc(100cqw * 8 / 1920);
  background: #fff;
  padding: calc(100cqw * 8 / 1920);
  display: block;
  box-shadow: 0 calc(100cqw * 4 / 1920) calc(100cqw * 20 / 1920) rgba(0, 0, 0, 0.35);
  object-fit: fill;
}

.stage-qr-label {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: calc(100cqw * 12 / 1920);
  max-width: calc(100cqw * 156 / 1920);
  line-height: 1.3;
  font-weight: 600;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.9),
    0 0 8px rgba(0, 0, 0, 0.7);
}

/* ---- KPIs / URLs / table ---- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.kpi strong {
  font-family: var(--display);
  font-size: 1.35rem;
}

.kpi-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.kpi-emphasis {
  border-color: rgba(0, 224, 143, 0.45);
  box-shadow: inset 0 0 0 1px rgba(0, 224, 143, 0.12);
}

.kpi-row-secondary {
  grid-template-columns: repeat(2, 1fr);
}

.fee-banner {
  background: rgba(240, 180, 41, 0.08);
  border: 1px solid rgba(240, 180, 41, 0.35);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.fee-banner strong {
  display: block;
  color: var(--warn);
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.fee-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.url-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.url-card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.url-card h2 {
  margin: 0;
  font-size: 1rem;
}

.url-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  flex: 1;
}

.url-card input {
  width: 100%;
  font-size: 0.8rem;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn-row .btn-secondary,
.btn-row button {
  flex: 1;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg1);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.muted {
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-paid {
  background: rgba(0, 224, 143, 0.15);
  color: var(--brand);
}

.badge-pending {
  background: rgba(240, 180, 41, 0.15);
  color: var(--warn);
}

.badge-other {
  background: rgba(139, 151, 168, 0.15);
  color: var(--muted);
}

/* ---- Learn ---- */
.tips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}

.tip-card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.tip-card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.tip-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.video-card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.video-frame {
  aspect-ratio: 16 / 9;
  background: #000;
}

.video-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.video-card h3 {
  margin: 12px 14px 4px;
  font-size: 0.95rem;
}

.video-card p {
  margin: 0 14px 14px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .url-grid,
  .tips-grid,
  .video-grid,
  .kpi-row,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ---- Language bar ---- */
.lang-bar-global {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
}

.lang-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.lang-label.inline {
  margin-bottom: 0;
}

.lang-select {
  background: var(--bg1);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.85rem;
  min-width: 120px;
}

.nav-badge {
  margin: 0;
  font-size: 0.75rem;
  color: var(--brand);
  font-weight: 700;
}

.step em {
  font-style: normal;
}

/* ---- Ads stage preview ---- */
.stage-ad {
  position: absolute;
  left: 50%;
  top: 88%;
  transform: translate(-50%, -50%);
  z-index: 4;
  box-sizing: border-box;
  min-width: 48px;
  max-width: 90%;
  width: 16.67%; /* ~320px on 1920 canvas */
  padding: 8px 12px;
  text-align: center;
  cursor: grab;
  border: 1px dashed rgba(240, 180, 41, 0.65);
  border-radius: 8px;
  background: rgba(240, 180, 41, 0.12);
  color: var(--warn);
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.35;
  pointer-events: none;
}

.stage-ad.is-on {
  opacity: 1;
  pointer-events: auto;
}

.stage-ad:active {
  cursor: grabbing;
}

.stage-ad.has-image {
  padding: 0;
  background: rgba(8, 12, 18, 0.45);
  overflow: visible;
}

.stage-ad.has-image .stage-ad-fallback {
  display: none;
}

.stage-ad-fallback {
  display: block;
  pointer-events: none;
}

.stage-ad-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 7px;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.stage-ad-image[hidden] {
  display: none !important;
}

.stage-ad-resize {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--warn);
  border: 2px solid #0d1218;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: nwse-resize;
  touch-action: none;
  z-index: 6;
}

.stage-ad:not(.is-on) .stage-ad-resize {
  display: none;
}

.stage-ad.is-resizing {
  cursor: nwse-resize;
}

.check-row {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  color: var(--text);
}

.check-row input {
  width: auto;
}

textarea {
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

/* ---- Messages ---- */
.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-head-row h2 {
  margin: 0;
  font-size: 1.1rem;
}

.filters-row {
  margin-bottom: 16px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.message-card.is-unread {
  border-color: rgba(0, 224, 143, 0.4);
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.message-meta strong {
  color: var(--text);
  font-size: 0.95rem;
}

.message-body {
  margin: 0 0 10px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 10px !important;
  font-size: 0.8rem !important;
}

.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: linear-gradient(90deg, #1a3a5c, #3a1a4a);
  color: #fff;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.impersonation-banner.hidden {
  display: none;
}

body.is-impersonating .app-shell {
  min-height: calc(100vh - 48px);
}

.sidebar-legal {
  display: flex;
  gap: 12px;
  margin: 12px 0 8px;
  font-size: 0.8rem;
}

.sidebar-legal a {
  color: var(--muted);
  text-decoration: none;
}

.sidebar-legal a:hover {
  color: var(--text);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.nav-section {
  margin: 0 0 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-json {
  margin-top: 12px;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: rgba(255, 255, 255, 0.04);
}

