/* Painel da Roleta — segue o Design System Redes (tokens semânticos; tema claro/escuro pela Central) */
:root {
  --redes-surface-raised: var(--redes-surface-alt);
  --redes-surface-emphasis: var(--redes-surface-alt);
  --redes-surface-hover: var(--redes-primary-light);
  --redes-control-border: var(--redes-line);
  --redes-text-secondary: var(--redes-muted);
  --redes-primary-surface: var(--redes-primary);
  --on-primary: #ffffff;
  --gap: 16px;
}
:root[data-theme=dark] { --on-primary: #ffffff; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; font-size: 14px; }
[hidden] { display: none !important; }
a { color: var(--redes-primary); }
:focus-visible { outline: 3px solid var(--redes-primary); outline-offset: 2px; border-radius: 6px; }

.offline { position: sticky; top: 0; z-index: 50; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 16px; background: var(--redes-warning-bg); color: var(--redes-warning-text); font-weight: 600; border-bottom: 1px solid currentColor; }

.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--redes-line); background: var(--redes-surface); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 180px; }
.logo-dot { width: 42px; height: 42px; display: grid; place-items: center; font-size: 24px; border-radius: 12px; background: var(--redes-primary-light); border: 1px solid var(--redes-line); }
.brand-name { font: 700 19px var(--redes-font-display); color: var(--redes-ink); letter-spacing: -.3px; }
.who { font-size: 12.5px; color: var(--redes-muted); text-align: right; line-height: 1.35; }
.who b { color: var(--redes-text); }

.tabs { display: flex; gap: 6px; padding: 10px 20px 0; overflow-x: auto; border-bottom: 1px solid var(--redes-line); background: var(--redes-bg); scrollbar-width: thin; position: sticky; top: 71px; z-index: 20; }
.tab { flex: none; padding: 11px 16px; min-height: 44px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--redes-muted); font: 600 13.5px var(--redes-font-main); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.tab[aria-current="page"] { color: var(--redes-primary); border-bottom-color: var(--redes-primary); }
.tab:hover { color: var(--redes-text); }
.tab .n { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--redes-primary-light); color: var(--redes-primary); }

.view { max-width: 1180px; margin: 0 auto; padding: 22px 20px 90px; outline: none; }
.loading { padding: 60px 0; text-align: center; color: var(--redes-muted); }
h1.page { margin: 0 0 4px; font: 700 26px var(--redes-font-display); color: var(--redes-ink); letter-spacing: -.5px; }
.sub { margin: 0 0 20px; color: var(--redes-muted); font-size: 13.5px; line-height: 1.5; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack { display: grid; gap: var(--gap); }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.panel-title { margin: 0 0 14px; font: 700 16px var(--redes-font-display); color: var(--redes-ink); }
.redes-panel { margin-bottom: 18px; padding: 20px; }
.redes-btn { min-height: 40px; }
.redes-btn.sm { min-height: 34px; padding: 6px 12px; font-size: 12.5px; }
.redes-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.redes-btn-primary { color: var(--on-primary); }
.redes-select, .redes-input, .redes-textarea { min-height: 42px; }
.redes-textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input[type=color] { width: 100%; height: 42px; padding: 4px; border-radius: var(--redes-radius-md); border: 1px solid var(--redes-line); background: var(--redes-surface); cursor: pointer; }
:root[data-theme=dark] input[type=color] { background: var(--redes-surface-raised); border-color: var(--redes-control-border); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--redes-primary); flex: none; }
.help { font-size: 12px; font-weight: 400; color: var(--redes-muted); line-height: 1.45; }
.redes-field { margin-bottom: 14px; }
.redes-field > span { font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--redes-line); border-radius: var(--redes-radius-md); background: var(--redes-surface-alt); cursor: pointer; }
.check b { display: block; color: var(--redes-ink); font-size: 13.5px; }
.status-active { background: var(--redes-success-bg); color: var(--redes-success-text); border: 1px solid currentColor; }
.status-draft, .status-ended { background: var(--redes-surface-alt); color: var(--redes-muted); border: 1px solid var(--redes-line); }
.status-paused { background: var(--redes-warning-bg); color: var(--redes-warning-text); border: 1px solid currentColor; }
.status-valid { background: var(--redes-success-bg); color: var(--redes-success-text); border: 1px solid currentColor; }
.status-redeemed { background: var(--redes-info-bg); color: var(--redes-info-text); border: 1px solid currentColor; }
.status-expired, .status-revoked, .status-failed { background: var(--redes-danger-bg); color: var(--redes-danger-text); border: 1px solid currentColor; }
.status-pending { background: var(--redes-warning-bg); color: var(--redes-warning-text); border: 1px solid currentColor; }
.status-sent { background: var(--redes-success-bg); color: var(--redes-success-text); border: 1px solid currentColor; }
.status-skipped { background: var(--redes-surface-raised); color: var(--redes-text-secondary); border: 1px solid var(--redes-line); }
.banner { padding: 12px 16px; border-radius: var(--redes-radius-md); border: 1px solid currentColor; font-size: 13px; line-height: 1.5; margin-bottom: 18px; }
.banner.warn { background: var(--redes-warning-bg); color: var(--redes-warning-text); }
.banner.info { background: var(--redes-info-bg); color: var(--redes-info-text); }
.banner b { color: inherit; }

/* KPIs */
.redes-kpi-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.redes-kpi-card { flex-direction: column; align-items: flex-start; gap: 4px; }
.redes-kpi-val { font-family: var(--redes-font-display); font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--redes-muted); }

/* gráficos */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--redes-muted); font: 11px var(--redes-font-main); }
.chart .grid { stroke: var(--redes-line); stroke-width: 1; }
.chart .b1 { fill: var(--redes-primary); opacity: .35; }
.chart .b2 { fill: var(--redes-primary); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--redes-muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--redes-primary); }
.legend i.l1 { opacity: .35; }
.hbar { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--redes-text); }
.hbar .bar { height: 12px; border-radius: 99px; background: var(--redes-surface-alt); border: 1px solid var(--redes-line); overflow: hidden; }
.hbar .bar i { display: block; height: 100%; border-radius: 99px; }
.hbar .val { font-variant-numeric: tabular-nums; color: var(--redes-muted); font-size: 12px; }

/* cards de campanha */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.camp { display: flex; flex-direction: column; gap: 12px; }
.camp h3 { margin: 0; font: 700 17px var(--redes-font-display); color: var(--redes-ink); }
.camp .meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.camp .meta div { padding: 8px 4px; border-radius: 10px; background: var(--redes-surface-alt); border: 1px solid var(--redes-line); }
.camp .meta b { display: block; font: 700 18px var(--redes-font-display); color: var(--redes-ink); }
.camp .meta span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--redes-muted); }
.linkbox { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--redes-surface-alt); border: 1px solid var(--redes-line); font-size: 12px; color: var(--redes-muted); }
.linkbox code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--redes-text); font-family: ui-monospace, Menlo, Consolas, monospace; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty { padding: 44px 20px; text-align: center; color: var(--redes-muted); }
.empty .big { font-size: 42px; }

/* sub-abas do editor */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 18px; padding: 5px; border-radius: 14px; background: var(--redes-surface-alt); border: 1px solid var(--redes-line); width: fit-content; max-width: 100%; overflow-x: auto; }
.subtab { padding: 9px 16px; min-height: 40px; border: 0; border-radius: 10px; background: none; color: var(--redes-muted); font: 600 13px var(--redes-font-main); cursor: pointer; white-space: nowrap; }
.subtab[aria-selected="true"] { background: var(--redes-surface); color: var(--redes-primary); box-shadow: var(--redes-shadow-sm); }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--redes-surface); border-top: 1px solid var(--redes-line); box-shadow: 0 -8px 24px rgba(0,0,0,.12); }
.savebar .dirty { color: var(--redes-warning-text); font-weight: 600; font-size: 13px; }

/* prêmios */
.dist { display: flex; height: 26px; border-radius: 99px; overflow: hidden; border: 1px solid var(--redes-line); margin: 6px 0 4px; }
.dist i { display: block; min-width: 2px; }
.prize { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--redes-line); border-radius: var(--redes-radius-lg); background: var(--redes-surface-alt); margin-bottom: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); align-items: end; }
.prize .redes-field { margin: 0; }
.prize .wide { grid-column: span 2; }
.prize .head { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
.prize .swatch { width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--redes-line); flex: none; }
.prize .pct { margin-left: auto; font: 700 14px var(--redes-font-display); color: var(--redes-primary); font-variant-numeric: tabular-nums; }
.prize .tools { display: flex; gap: 6px; }
.prize img.pimg { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; border: 1px solid var(--redes-line); }
.iconbtn { width: 38px; height: 38px; min-height: 38px; padding: 0; display: inline-grid; place-items: center; }
.previewframe { width: 100%; height: min(78vh, 760px); border: 0; border-radius: 18px; background: #000; }

/* tabelas → cartões no celular */
.redes-table-wrap { margin-bottom: 8px; }
.redes-table td, .redes-table th { white-space: nowrap; }
.redes-table td .wrap { white-space: normal; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--redes-muted); font-size: 13px; }
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; align-items: end; }
.filters .redes-field { margin: 0; }
.lookup { display: grid; gap: 12px; }
.lookup-res { padding: 16px; border-radius: var(--redes-radius-lg); border: 1px solid var(--redes-line); background: var(--redes-surface-alt); }
.lookup-res h3 { margin: 6px 0 2px; font: 700 20px var(--redes-font-display); color: var(--redes-ink); }
.qrshare { display: inline-block; padding: 12px; background: #fff; border-radius: 16px; } /* quiet zone do QR: exceção técnica prevista */
.qrshare canvas { display: block; width: 220px; height: 220px; image-rendering: pixelated; }

/* modal e toasts */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { width: min(560px, 100%); background: var(--redes-surface); border: 1px solid var(--redes-line); border-radius: 18px; padding: 22px; box-shadow: var(--redes-shadow-lg); }
.modal.big { width: min(440px, 100%); }
.modal h3 { margin: 0 0 8px; font: 700 18px var(--redes-font-display); color: var(--redes-ink); }
.modal p { margin: 0 0 16px; color: var(--redes-muted); line-height: 1.5; }
.modal .actions { justify-content: flex-end; }
.toasts { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 70; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--redes-surface-emphasis); color: var(--redes-text); border: 1px solid var(--redes-line); box-shadow: var(--redes-shadow-md); font-weight: 600; font-size: 13.5px; animation: pop .2s ease both; }
.toast.err { border-color: var(--redes-danger-text); color: var(--redes-danger-text); }
.toast.ok { border-color: var(--redes-success-text); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 720px) {
  .view { padding: 16px 14px 100px; }
  .topbar { padding: 10px 14px; } .tabs { top: 0; position: static; padding: 6px 10px 0; }
  .who { display: none; }
  h1.page { font-size: 22px; }
  .redes-table.stack-m thead { display: none; }
  .redes-table.stack-m, .redes-table.stack-m tbody, .redes-table.stack-m tr, .redes-table.stack-m td { display: block; width: 100%; }
  .redes-table.stack-m tr { padding: 10px 12px; border-bottom: 1px solid var(--redes-line); }
  .redes-table.stack-m td { padding: 4px 0; border: 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .redes-table.stack-m td::before { content: attr(data-l); color: var(--redes-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
  .redes-table.stack-m td.act { justify-content: flex-end; }
  .redes-table.stack-m td.act::before { content: none; }
  .prize .wide { grid-column: auto; }
  .camp .meta b { font-size: 16px; }
  .cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* seletor de temas */
.themes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.themecard { display: grid; gap: 8px; padding: 8px; border: 2px solid var(--redes-line); border-radius: 14px; background: var(--redes-surface-alt); cursor: pointer; text-align: left; font: inherit; color: var(--redes-text); }
.themecard:hover { border-color: var(--redes-muted); }
.themecard[aria-pressed="true"] { border-color: var(--redes-primary); box-shadow: 0 0 0 3px var(--redes-primary-light); }
.tprev { position: relative; height: 74px; border-radius: 10px; border: 2px solid; overflow: hidden; }
.tdot { position: absolute; top: 10px; left: 10px; width: 22px; height: 22px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.tstrip { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; display: flex; }
.tstrip i { flex: 1; }
.tname { font-weight: 600; font-size: 12.5px; }

/* prévia ao vivo (aba Visual) */
.vis-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.vis-left { min-width: 0; }
.livepane { order: -1; padding: 14px; border: 1px solid var(--redes-line); border-radius: var(--redes-radius-lg); background: var(--redes-surface); }
.phone { margin: 10px auto 0; width: 100%; max-width: 340px; aspect-ratio: 9 / 17; border: 6px solid #111; border-radius: 30px; overflow: hidden; background: #000; box-shadow: var(--redes-shadow-md); }
.liveframe { width: 100%; height: 100%; border: 0; display: block; }
@media (min-width: 1000px) {
  .vis-layout { grid-template-columns: minmax(0, 1fr) 380px; }
  .livepane { order: 0; position: sticky; top: 130px; }
}
