/* =====================================================================
   Painel da operação — dark luxury / dourado champanhe
   ===================================================================== */
:root {
  --bg-0: #0c0a08;
  --bg-1: #14110d;
  --surface: rgba(255, 244, 224, 0.035);
  --surface-hover: rgba(255, 244, 224, 0.06);
  --border: rgba(212, 175, 55, 0.14);
  --border-strong: rgba(212, 175, 55, 0.35);
  --text: #efe9df;
  --text-dim: #a89f90;
  --text-faint: #6f675a;
  --gold: #d4af37;
  --gold-soft: #e8cd7f;
  --gold-deep: #9a7b1e;
  --green: #7fbf7f;
  --red: #d97b6c;
  --blue: #8fb4d9;
  --radius: 16px;
  --font-display: "Fraunces", serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(212, 175, 55, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(120, 90, 30, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 40%);
  min-height: 100vh;
  padding: 28px clamp(16px, 4vw, 48px) 60px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- entrada em cascata ---------- */
.reveal { opacity: 0; transform: translateY(14px); animation: rise .7s cubic-bezier(.16,1,.3,1) forwards; }
.reveal:nth-of-type(1) { animation-delay: .05s } .reveal:nth-of-type(2) { animation-delay: .12s }
.kpi-row .reveal:nth-child(1) { animation-delay: .18s } .kpi-row .reveal:nth-child(2) { animation-delay: .26s }
.kpi-row .reveal:nth-child(3) { animation-delay: .34s } .kpi-row .reveal:nth-child(4) { animation-delay: .42s }
.grid-2 .reveal:nth-child(1) { animation-delay: .5s } .grid-2 .reveal:nth-child(2) { animation-delay: .58s }
.grid-3 .reveal:nth-child(1) { animation-delay: .66s } .grid-3 .reveal:nth-child(2) { animation-delay: .74s }
.grid-3 .reveal:nth-child(3) { animation-delay: .82s }
.table-card { animation-delay: .9s } .foot { animation-delay: 1s }
@keyframes rise { to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none }
  .goal-fill, .funnel-fill, .bar-fill, .ring-fg { transition: none !important }
}

/* ---------- topo ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center; font-size: 17px;
  color: var(--gold-soft); border: 1px solid var(--border-strong); border-radius: 12px;
  background: linear-gradient(160deg, rgba(212,175,55,.16), rgba(212,175,55,.02));
}
h1 { font-family: var(--font-display); font-weight: 500; font-size: 24px; letter-spacing: .2px; }
.brand-sub { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; letter-spacing: .4px; }

.period-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.tab {
  font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--text-dim);
  background: none; border: 0; border-radius: 999px; padding: 8px 18px; cursor: pointer;
  transition: color .25s, background .25s;
}
.tab:hover { color: var(--text) }
.tab.active { color: #1a1509; background: linear-gradient(160deg, var(--gold-soft), var(--gold)); font-weight: 600; }
.tab:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- alertas de decisão ---------- */
.alerts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 22px; }
.alert {
  display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5;
  color: var(--text-dim); padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
}
.alert strong { color: var(--text); font-weight: 600; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; animation: pulse 2.4s ease-in-out infinite; }
.alert.warn .alert-dot { background: var(--red) } .alert.gold .alert-dot { background: var(--gold) }
.alert.info .alert-dot { background: var(--blue) }
@keyframes pulse { 50% { opacity: .35 } }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; transition: transform .35s cubic-bezier(.16,1,.3,1), border-color .35s, background .35s;
}
.card:hover { transform: translateY(-3px); border-color: var(--border-strong); background: var(--surface-hover); }
.card h2 { font-size: 13px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--text-dim); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.head-stat { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.head-stat strong { color: var(--gold-soft); }

/* ---------- KPIs ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.kpi-value { font-family: var(--font-display); font-size: clamp(34px, 3.4vw, 46px); font-weight: 500; line-height: 1.05; }
.kpi-value small.unit { font-size: .5em; color: var(--text-dim); margin-left: 2px; }
.gold-text {
  background: linear-gradient(160deg, #f4dfa8 10%, var(--gold) 55%, var(--gold-deep));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.kpi-note { font-size: 12.5px; color: var(--text-faint); margin-top: 10px; }
.kpi-note strong { color: var(--text-dim); font-weight: 600; }
.mt { margin-top: 14px }

.badge { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; letter-spacing: .3px; }
.badge.up { color: var(--green); background: rgba(127,191,127,.1); border: 1px solid rgba(127,191,127,.25); }
.badge.down { color: var(--red); background: rgba(217,123,108,.1); border: 1px solid rgba(217,123,108,.25); }
.gold-badge { color: var(--gold-soft); background: rgba(212,175,55,.1); border: 1px solid var(--border-strong); }

/* meta do mês */
.goal { margin-top: 16px }
.goal-track { height: 6px; border-radius: 999px; background: rgba(255,244,224,.08); overflow: hidden; }
.goal-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-soft));
  transition: width 1.4s cubic-bezier(.16,1,.3,1) .4s;
}
.goal-label { font-size: 12px; color: var(--text-faint); margin-top: 8px; }
.goal-label span { color: var(--gold-soft); font-weight: 600; }

/* anel da taxa de pagamento */
.ring-wrap { position: relative; width: 112px; margin: 4px auto 0; }
.ring { width: 112px; height: 112px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring-bg { stroke: rgba(255,244,224,.08); }
.ring-fg { stroke: url(#nogrady, var(--gold)); stroke: var(--gold); stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset 1.6s cubic-bezier(.16,1,.3,1) .5s; }
.ring-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 1px; font-family: var(--font-display); font-size: 27px; }
.ring-value small { font-size: 14px; color: var(--text-dim); }
.kpi .ring-wrap + .kpi-note { text-align: center; }

/* ---------- grids ---------- */
.grid-2 { display: grid; grid-template-columns: 1.9fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 1080px) { .grid-2, .grid-3 { grid-template-columns: 1fr } }

.chart-box { position: relative; height: 260px; }
.donut-box { height: 210px; display: grid; place-items: center; }
.donut-center { position: absolute; text-align: center; pointer-events: none; }
.donut-num { font-family: var(--font-display); font-size: 26px; }
.donut-lbl { font-size: 11px; color: var(--text-faint); letter-spacing: .5px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; }
.legend li { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- funil da régua ---------- */
.funnel { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.funnel li { font-size: 12.5px; }
.funnel-head { display: flex; justify-content: space-between; color: var(--text-dim); margin-bottom: 5px; }
.funnel-head strong { color: var(--text); }
.funnel-track { height: 8px; border-radius: 999px; background: rgba(255,244,224,.07); overflow: hidden; }
.funnel-fill { height: 100%; width: 0; border-radius: 999px; transition: width 1.2s cubic-bezier(.16,1,.3,1); }
.funnel-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.funnel-total p:first-child { font-size: 12px; color: var(--text-faint); }
.funnel-money { font-family: var(--font-display); font-size: 26px; }

/* ---------- barras de canal ---------- */
.bars { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.bars li { font-size: 12.5px; }
.bar-head { display: flex; justify-content: space-between; color: var(--text-dim); margin-bottom: 5px; }
.bar-head strong { color: var(--text); }
.bar-track { height: 8px; border-radius: 999px; background: rgba(255,244,224,.07); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--gold-deep), var(--gold-soft)); transition: width 1.2s cubic-bezier(.16,1,.3,1); }

/* ---------- ROAS ---------- */
.roas { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.roas li {
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: rgba(255,244,224,.02); transition: border-color .25s, transform .25s;
}
.roas li:hover { border-color: var(--border-strong); transform: translateX(3px); }
.roas .name { color: var(--text-dim); }
.roas .val { font-family: var(--font-display); font-size: 19px; color: var(--gold-soft); }
.roas .val small { font-size: 12px; color: var(--text-faint); font-family: var(--font-body); }

/* ---------- tabela fila ---------- */
.table-card { margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--text-faint); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); }
td { padding: 13px 14px; border-bottom: 1px solid rgba(212,175,55,.07); color: var(--text-dim); }
td:first-child { color: var(--text); font-weight: 500; }
tbody tr { transition: background .2s; }
tbody tr:hover { background: rgba(212,175,55,.05); }
tbody tr:last-child td { border-bottom: 0; }
.tier { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; letter-spacing: .4px; }
.tier.diamante { color: #cfe3f5; background: rgba(143,180,217,.12); border: 1px solid rgba(143,180,217,.3); }
.tier.ouro { color: var(--gold-soft); background: rgba(212,175,55,.1); border: 1px solid var(--border-strong); }
.tier.prata { color: #cfcabe; background: rgba(207,202,190,.08); border: 1px solid rgba(207,202,190,.25); }
.tier.novo { color: var(--green); background: rgba(127,191,127,.08); border: 1px solid rgba(127,191,127,.25); }
.money { color: var(--gold-soft); font-weight: 600; }
.act-btn {
  font-size: 12px; font-weight: 600; color: var(--gold-soft); background: none; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 14px;
  transition: background .25s, color .25s;
}
.act-btn:hover { background: linear-gradient(160deg, var(--gold-soft), var(--gold)); color: #1a1509; }

.foot { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 26px; }
.foot code { color: var(--text-dim); font-size: 11.5px; }

/* ---------- KPIs clicáveis ---------- */
.clickable { cursor: pointer; position: relative; }
.drill-hint {
  position: absolute; right: 14px; bottom: 12px; font-size: 11px; color: var(--gold-soft);
  opacity: 0; transition: opacity .25s;
}
.clickable:hover .drill-hint { opacity: 1; }
.ia-status { color: var(--text-faint); }
.ia-status.on { color: var(--green); }

/* ---------- grupos & IA ---------- */
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 1080px) { .grid-2b { grid-template-columns: 1fr } }
.seg-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.seg-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: rgba(255,244,224,.02); transition: border-color .25s;
}
.seg-list li:hover { border-color: var(--border-strong); }
.seg-nome { font-size: 14px; font-weight: 600; }
.seg-meta { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 18px 8px; }

.gold-cta { background: linear-gradient(160deg, var(--gold-soft), var(--gold)); color: #1a1509; border-color: transparent; }
.gold-cta:hover { filter: brightness(1.08); color: #1a1509; }
.gold-cta:disabled { opacity: .55; cursor: wait; }

.ia-out { min-height: 120px; }
.ia-placeholder { font-size: 13px; color: var(--text-faint); padding: 20px 4px; }
.ia-texto p { font-size: 13.5px; line-height: 1.65; color: var(--text-dim); margin-bottom: 8px; }
.ia-fonte { font-size: 11.5px; color: var(--gold-soft); margin-top: 10px; }
.ia-note { font-size: 11.5px; color: var(--gold-soft); min-height: 16px; }

/* ---------- modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; }
.modal-root[hidden] { display: none; }   /* hidden precisa vencer o display:grid, senão o overlay come todos os cliques */
.modal-backdrop { position: absolute; inset: 0; background: rgba(8,6,4,.7); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .25s; }
.modal {
  position: relative; width: min(760px, calc(100vw - 32px)); max-height: 84vh; overflow: auto;
  background: #171310; border: 1px solid var(--border-strong); border-radius: 18px;
  padding: 22px 24px; transform: translateY(16px) scale(.98); opacity: 0;
  transition: transform .3s cubic-bezier(.16,1,.3,1), opacity .3s;
}
.modal-root.open .modal-backdrop { opacity: 1; }
.modal-root.open .modal { transform: none; opacity: 1; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.modal-x { background: none; border: 0; color: var(--text-dim); font-size: 15px; cursor: pointer; padding: 6px; }
.modal-x:hover { color: var(--text); }
.modal-body h4 { font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px; }
.mt-h { margin-top: 20px; }
.modal-note { font-size: 12px; color: var(--text-faint); margin-top: 14px; line-height: 1.5; }
.drill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .drill-grid { grid-template-columns: 1fr } }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { font-size: 10.5px; padding: 7px 10px; }
.mini-table td { padding: 9px 10px; }
.cta-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.cta-row.space { justify-content: space-between; }

/* ---------- formulários ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.f-label { font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }
.f-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* `input:not([type])` está aqui porque input sem type É input de texto — só
   que o seletor de atributo não casa, e o campo sai branco no tema escuro.
   Acontecia em precos.js, reativacao.js e no atacado. */
input:not([type]), input[type="text"], input[type="number"], select, textarea {
  font-family: var(--font-body); font-size: 14px; color: var(--text);
  background: rgba(255,244,224,.04); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; outline: none; transition: border-color .25s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; }
select option { background: #171310; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 12px; font-weight: 500; color: var(--text-dim); background: none; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; transition: all .2s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.on { color: #1a1509; background: linear-gradient(160deg, var(--gold-soft), var(--gold)); border-color: transparent; font-weight: 600; }
.preview-line { font-size: 13px; color: var(--gold-soft); padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 9px; }

/* ---------- status e toasts ---------- */
.status-chip { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  color: var(--text-dim); background: rgba(255,244,224,.06); border: 1px solid var(--border); }
.status-chip.wait { color: var(--gold-soft); border-color: var(--border-strong); background: rgba(212,175,55,.08); }
.msg-cell { max-width: 320px; color: var(--text-faint); }
.done-row { opacity: 0; transform: translateX(20px); transition: all .6s; }
.done-row td { text-decoration: line-through; }

/* ---------- jornada de compra ---------- */
.jornada { margin-bottom: 14px; }
.sec-title { font-family: var(--font-display); font-size: 19px; font-weight: 500; color: var(--text); text-transform: none; letter-spacing: 0; }
.jor-head { margin-bottom: 14px; }
.jor-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
@media (max-width: 1200px) { .jor-grid { grid-template-columns: repeat(4, 1fr) } }
@media (max-width: 760px) { .jor-grid { grid-template-columns: repeat(2, 1fr) } }
.jor-card {
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--gold);
  border-radius: 12px; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 4px;
  transition: transform .3s cubic-bezier(.16,1,.3,1), border-color .3s, background .3s;
}
.jor-card:hover { transform: translateY(-3px); background: var(--surface-hover); }
.jor-count { font-family: var(--font-display); font-size: 30px; line-height: 1; }
.jor-nome { font-size: 12.5px; font-weight: 600; color: var(--text); }
.jor-estr { font-size: 11px; color: var(--text-faint); line-height: 1.45; min-height: 32px; }
.jor-meta { font-size: 11px; color: var(--text-faint); }
.jor-meta strong { color: var(--gold-soft); }
.jor-acoes { display: flex; gap: 6px; margin-top: 8px; }
.jor-btn {
  flex: 1; font-size: 10.5px; font-weight: 600; padding: 5px 4px; border-radius: 999px;
  color: var(--text-dim); background: none; border: 1px solid var(--border); cursor: pointer;
  transition: all .2s; white-space: nowrap;
}
.jor-btn:hover { border-color: var(--border-strong); color: var(--text); }
.jor-btn.gold { color: var(--gold-soft); border-color: var(--border-strong); }
.jor-btn.gold:hover { background: linear-gradient(160deg, var(--gold-soft), var(--gold)); color: #1a1509; }

/* ---------- CRM ---------- */
.crm-head { flex-wrap: wrap; }
.crm-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.crm-tools input[type="search"] { min-width: 220px; }
.crm-tools input, .crm-tools select { padding: 8px 12px; font-size: 13px; }
.cli-row { cursor: pointer; }
.mom-chip { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  color: var(--blue); background: rgba(143,180,217,.08); border: 1px solid rgba(143,180,217,.25); }
.vip-mini { font-size: 9.5px; font-weight: 700; letter-spacing: .6px; padding: 2px 7px;
  border-radius: 999px; color: #1a1509; background: linear-gradient(160deg, var(--gold-soft), var(--gold)); vertical-align: 2px; }
.pag { display: flex; justify-content: space-between; align-items: center; margin-top: 14px;
  font-size: 12.5px; color: var(--text-faint); }
.pag-btns { display: flex; gap: 8px; }
.pag .act-btn:disabled { opacity: .35; cursor: default; }

/* ---------- perfil 360 ---------- */
.perfil-top { margin-bottom: 16px; }
.perfil-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.perfil-fone { font-size: 12.5px; color: var(--text-faint); margin-top: 8px; }
.opt-chip { font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  color: var(--red); border: 1px solid rgba(217,123,108,.35); }
.opt-chip.ok { color: var(--green); border-color: rgba(127,191,127,.35); }
.perfil-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 640px) { .perfil-grid { grid-template-columns: repeat(2, 1fr) } }
.pstat { background: rgba(255,244,224,.03); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; text-align: center; }
.pstat-v { font-family: var(--font-display); font-size: 20px; color: var(--gold-soft); }
.pstat-l { font-size: 10.5px; color: var(--text-faint); margin-top: 4px; }
.proxima-acao { font-size: 13px; color: var(--text-dim); padding: 12px 14px;
  border: 1px dashed var(--border-strong); border-radius: 10px; margin-bottom: 6px; }
.proxima-acao strong { color: var(--gold-soft); }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast {
  font-size: 13.5px; color: var(--text); background: #1d1813; border: 1px solid var(--border-strong);
  border-left: 3px solid var(--gold); border-radius: 10px; padding: 12px 16px; max-width: 360px;
  opacity: 0; transform: translateY(10px); transition: all .35s cubic-bezier(.16,1,.3,1);
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-left-color: var(--red); }
