/* ==========================================================================
   Bot de Ofertas — sistema visual
   Neutro + um acento (índigo). Claro e escuro com os mesmos papéis.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f3f3f6;
  --surface-3: #ebebf0;
  --border: #e6e6eb;
  --border-strong: #d4d4dc;
  --text: #17171c;
  --text-2: #3f3f48;
  --muted: #74747f;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --ok-soft: #ebf8ef;
  --bad: #c81e1e;
  --bad-soft: #fdeeee;
  --warn: #a15c07;
  --warn-soft: #fff6e5;
  --link: #4f46e5;
  --focus: 0 0 0 3px rgba(79, 70, 229, .25);
  --shadow: 0 1px 2px rgba(16, 16, 24, .04), 0 1px 1px rgba(16, 16, 24, .02);
  --shadow-lg: 0 8px 24px rgba(16, 16, 24, .08);
  --radius: 14px;
  --radius-sm: 9px;
  /* prévia da mensagem (estilo WhatsApp) */
  --chat-bg: #efeae2;
  --bubble: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-link: #027eb5;
  /* compatibilidade com nomes antigos */
  --ok-bg: var(--ok-soft);
  --bad-bg: var(--bad-soft);
  --warn-bg: var(--warn-soft);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c0c10;
    --surface: #141419;
    --surface-2: #1b1b22;
    --surface-3: #23232c;
    --border: #25252e;
    --border-strong: #33333e;
    --text: #ececf1;
    --text-2: #c9c9d3;
    --muted: #9696a3;
    --accent: #8b8cf6;
    --accent-hover: #a3a4fa;
    --accent-soft: #1d1c3d;
    --accent-ink: #0c0c10;
    --ok: #4ade80;
    --ok-soft: #0e2a19;
    --bad: #f87171;
    --bad-soft: #2d1414;
    --warn: #fbbf24;
    --warn-soft: #2b2009;
    --link: #a3a4fa;
    --focus: 0 0 0 3px rgba(139, 140, 246, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .45);
    --chat-bg: #0b141a;
    --bubble: #202c33;
    --bubble-out: #005c4b;
    --bubble-link: #53bdeb;
  }
}

/* --- base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { letter-spacing: -.01em; margin: 0; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 620; margin-bottom: 12px; }
code { font: 12.5px/1.4 ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--surface-2);
       padding: 1px 6px; border-radius: 6px; word-break: break-all; }
img { max-width: 100%; }
.muted { color: var(--muted); font-size: 13.5px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
details summary { cursor: pointer; font-weight: 560; color: var(--text-2); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }

/* --- barra superior -------------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 88%, transparent);
          backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 680; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #ec4899);
        display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 800; }
.nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); font-weight: 520; font-size: 14px; padding: 7px 11px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-3); }
.nav .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13.5px; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
          display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-chip form { margin: 0; }
@media (max-width: 1000px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 6px; gap: 6px 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .user-chip { margin-left: auto; }
}
@media (max-width: 640px) { .user-chip .who { display: none; } }

/* --- cabeçalho da página ---------------------------------------------------- */
main.wrap { padding-top: 26px; padding-bottom: 48px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 18px; }
.page-head h1 { margin-right: auto; }
.page-sub { color: var(--muted); font-size: 14px; margin: -10px 0 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.toolbar form { margin: 0; }
.status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.clock { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 15px; color: var(--text-2); }

/* --- cartões ------------------------------------------------------------------ */
section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
          padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
section > h2:first-child { display: flex; align-items: center; gap: 8px; }
section.alert { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); background:
                linear-gradient(0deg, var(--bad-soft), var(--bad-soft)), var(--surface); }
section.note { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
main.single, .narrow { max-width: 860px; margin-left: auto; margin-right: auto; }

/* --- botões ------------------------------------------------------------------- */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 560; line-height: 1; cursor: pointer;
  padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); transition: background .12s, border-color .12s, color .12s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.approve { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
button.approve:hover { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); }
button.reject { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
button.reject:hover { background: var(--bad-soft); }
button.link { background: none; border: 0; padding: 4px 6px; color: var(--muted); font-weight: 520; }
button.link:hover { color: var(--text); background: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.small { padding: 7px 10px; font-size: 13px; }

/* --- etiquetas ---------------------------------------------------------------- */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
       padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.demo { background: var(--warn-soft); color: var(--warn); }
.tag.neutral { background: var(--surface-2); color: var(--muted); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* --- avisos ---------------------------------------------------------------------- */
.flash { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft);
         color: var(--text); font-size: 14px; border: 1px solid transparent; }
.flash.error { background: var(--bad-soft); color: var(--bad); }

/* --- formulários ---------------------------------------------------------------- */
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 11px; max-width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input:not([type=checkbox]):not([type=radio]), select { height: 40px; line-height: 1.2; }
input[readonly] { background: var(--surface-2); }
label { font-size: 13px; color: var(--muted); font-weight: 520; }
form.stack { display: grid; gap: 14px; }
form.stack label, .row2 label, form.inline label, .filters label { display: grid; gap: 6px; align-content: start; }
form.stack button { justify-self: start; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; margin: 0 0 14px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.reauth { border-top: 1px dashed var(--border-strong); padding-top: 14px; }
textarea.copy { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; resize: none; }
textarea.copy.big { font-size: 22px; text-align: center; letter-spacing: 1px; padding: 14px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 14px; }

/* --- tabelas ------------------------------------------------------------------------ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 560; font-size: 12.5px; padding: 8px 10px;
     border-bottom: 1px solid var(--border); }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.highlight td { background: var(--ok-soft); }
table.num td:not(:first-child), table.num th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.actions-col { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.actions-col form { margin: 0; }
td form.inline { margin: 0; }

/* --- ofertas (lista do dia) ------------------------------------------------------------ */
.card { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 14px; padding: 16px 0;
        border-top: 1px solid var(--border); }
.card:first-of-type { border-top: 0; padding-top: 4px; }
.card img { width: 88px; height: 88px; border-radius: 12px; object-fit: cover; background: var(--surface-2); }
.card .row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.card .row form { margin: 0; }
.facts { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; }
.facts b { color: var(--text); font-weight: 620; }
.preview { background: var(--chat-bg); border-radius: 12px; padding: 10px; }
.bubble { background: var(--bubble); border-radius: 10px; padding: 8px 10px; font-size: 14px;
          overflow-wrap: anywhere; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); color: var(--text); }
.bubble a { color: var(--bubble-link); }
.chat { background: var(--chat-bg); border-radius: 12px; padding: 14px; min-height: 140px; max-height: 720px;
        overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.chat .bubble { background: var(--bubble-out); align-self: flex-end; max-width: 340px; width: 100%; }
.chat .bubble img { width: 100%; border-radius: 8px; display: block; margin-bottom: 6px; }
.chat .bubble.faded { opacity: .6; }
.chat .meta { text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; }
.chat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0;
              border-top: 1px solid var(--border); }
.row-inline form { margin: 0; }
.row-inline span { flex: 1 1 200px; }
ol.log { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); max-height: 260px; overflow-y: auto; }
ol.log li { padding: 6px 0; border-top: 1px solid var(--border); }
ol.log li:first-child { border-top: 0; }
ol.log li.warn, ol.log li.error { color: var(--bad); }

/* --- login / primeiro acesso ------------------------------------------------------------- */
body.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px;
                  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 30px;
             width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login-box.wide { max-width: 480px; }
.login-box .brand { margin-bottom: 18px; }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box h2 { margin: 8px 0 0; font-size: 14px; color: var(--text); }
.login-box form { display: grid; gap: 14px; margin-top: 18px; }
.login-box label { display: grid; gap: 6px; }
.login-box input { padding: 11px 12px; }
.login-box button.primary { justify-content: center; padding: 12px; margin-top: 4px; }
.login-box > form + form { margin-top: 8px; display: block; text-align: center; }
.qr { width: 240px; max-width: 100%; height: auto; background: #fff; padding: 10px; border-radius: 12px;
      display: block; border: 1px solid var(--border); }

/* --- conta de afiliado ---------------------------------------------------------------------- */
.platform { border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: grid; gap: 12px; }
.platform-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.platform-head h3 { font-size: 15px; margin-right: auto; }

/* --- cobrança ----------------------------------------------------------------------------- */
.invoice { border-top: 1px solid var(--border); padding: 12px 0; }
.invoice:first-of-type { border-top: 0; }
.invoice-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }

/* --- gráficos (skill dataviz: cores validadas para claro e escuro) ------------------------- */
.viz-root { --series-1: #2a78d6; --series-2: #eb6834; --grid: #ececf0; --baseline: #d4d4dc; --tick: #8a8a95; }
@media (prefers-color-scheme: dark) {
  .viz-root { --series-1: #3987e5; --series-2: #d95926; --grid: #24242c; --baseline: #34343e; --tick: #8a8a95; }
}
svg.chart { width: 100%; height: auto; display: block; margin-top: 4px; }
svg.chart .s1 { fill: var(--series-1); }
svg.chart .s2 { fill: var(--series-2); }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { stroke: var(--baseline); stroke-width: 1; }
svg.chart .tick { fill: var(--tick); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.chart .label { fill: var(--text); font-size: 13px; }
svg.chart .value { fill: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
svg.chart .hit { fill: transparent; }
svg.chart .hit:hover { fill: var(--text); fill-opacity: .05; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .key.s1 { background: var(--series-1); }
.legend .key.s2 { background: var(--series-2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
        box-shadow: var(--shadow); }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 520; }
.tile-value { font-size: 26px; font-weight: 680; margin-top: 4px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.tile.hero { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.tile.hero .tile-value { font-size: 34px; }
.tile-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.tiles + section, section + .tiles, .tiles + .toolbar { margin-top: 16px; }

@media (max-width: 640px) { section { padding: 16px; overflow-x: auto; } }

/* Página de demonstração (layout antigo, só local) */
body > header:not(.topbar) { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 0; }
body > header:not(.topbar) h1 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
body > header:not(.topbar) .status, body > header:not(.topbar) .actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
body > header:not(.topbar) .actions form { margin: 0; }

/* Planos */
.plans { display: grid; gap: 8px; }
.plan-option { display: flex !important; gap: 12px; align-items: flex-start; border: 1px solid var(--border-strong);
               border-radius: 12px; padding: 12px 14px; cursor: pointer; color: var(--text); font-size: 14px; }
.plan-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.plan-option input { height: auto; margin-top: 3px; accent-color: var(--accent); }
.plan-option > span { display: grid; gap: 2px; }
.plan-price { color: var(--muted); font-weight: 520; }
.plan-row { padding: 10px 0; border-top: 1px solid var(--border); margin: 0; }
.plan-row:first-of-type { border-top: 0; }
.nowrap { white-space: nowrap; }
.pager { align-items: center; margin: 12px 0 0; }
a.btn.small { padding: 7px 10px; font-size: 13px; }
