:root {
  --bg:        #0e1117;
  --bg-2:      #151a23;
  --panel:     #1a212c;
  --panel-2:   #212a37;
  --border:    #2a3442;
  --txt:       #e6edf3;
  --txt-dim:   #9aa7b4;
  --txt-mut:   #66727f;
  --brand:     #ff6a00;   /* laranja Alibaba */
  --brand-2:   #ffd21e;   /* amarelo ML */
  --green:     #22c55e;
  --red:       #ef4444;
  --radius:    14px;
  --shadow:    0 10px 30px rgba(0,0,0,.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Sidebars ---------- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar--right { border-right: none; border-left: 1px solid var(--border); }

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar__scroll { overflow-y: auto; padding: 16px 18px 40px; flex: 1; }
.sidebar__hint { color: var(--txt-dim); font-size: 12.5px; line-height: 1.5; margin-bottom: 18px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand__logo { font-size: 26px; }
.brand strong { display: block; font-size: 16px; letter-spacing: .2px; }
.brand small { color: var(--txt-mut); font-size: 11px; }

/* ---------- Config groups ---------- */
.cfg-group { margin-bottom: 22px; }
.cfg-group h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--txt-dim); display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; font-weight: 700;
}
.cfg-group h3 span { font-size: 14px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--txt-dim); margin-bottom: 5px; }
.field input, .field select, .select {
  width: 100%; background: var(--panel); border: 1px solid var(--border);
  color: var(--txt); border-radius: 9px; padding: 9px 11px; font-size: 14px;
  font-family: var(--font); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255,106,0,.15);
}
.field__note { display: block; font-size: 11px; color: var(--txt-mut); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.link-btn {
  background: none; border: none; color: var(--brand); cursor: pointer;
  font-size: 12.5px; padding: 2px 0; font-family: var(--font);
}
.link-btn:hover { text-decoration: underline; }

.cfg-actions { margin: 8px 0 14px; }
.disclaimer { font-size: 11px; color: var(--txt-mut); line-height: 1.5; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--txt);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: var(--font); transition: transform .08s, filter .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(135deg, var(--brand), #ff8c33);
  border: none; color: #fff; box-shadow: 0 4px 14px rgba(255,106,0,.35);
}
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: transparent; width: 100%; }
.btn--ghost:hover { background: var(--panel); }
.btn--ml {
  background: linear-gradient(135deg, #ffe600, #ffcc00); border: none; color: #2d3277;
  box-shadow: 0 4px 14px rgba(255,214,0,.28);
}
.btn--ml:hover { filter: brightness(1.04); }
.icon-btn {
  background: var(--panel); border: 1px solid var(--border); color: var(--txt);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--panel-2); }

/* ---------- Main ---------- */
.main { min-width: 0; padding: 22px 26px 40px; }
.topbar { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
.topbar__title { flex: 1; }
.topbar h1 { font-size: 23px; line-height: 1.2; margin-bottom: 5px; }
.topbar p { color: var(--txt-dim); font-size: 13.5px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; flex: 1; min-width: 200px;
}
.search span { color: var(--txt-mut); }
.search input { background: none; border: none; color: var(--txt); padding: 10px 0; width: 100%; font-size: 14px; outline: none; font-family: var(--font); }
.select { width: auto; padding-right: 30px; cursor: pointer; }

/* ---------- Chips (nichos) ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 20px; }
.chip {
  white-space: nowrap; background: var(--panel); border: 1px solid var(--border);
  color: var(--txt-dim); padding: 8px 14px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-family: var(--font); transition: all .15s; display: flex; gap: 6px; align-items: center;
}
.chip:hover { border-color: var(--brand); color: var(--txt); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------- Banner de modo ao vivo ---------- */
.live-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(255,214,0,.08); border: 1px solid rgba(255,214,0,.35);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; color: var(--txt-dim);
}
.live-banner[hidden] { display: none; }
.live-banner b { color: var(--txt); }
.live-banner code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---------- Grid de produtos ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

/* ---------- Card ao vivo (ML) ---------- */
.card--live { border-color: rgba(255,214,0,.30); }
.card--live:hover { border-color: rgba(255,214,0,.55); }
.card__thumb {
  height: 130px; display: grid; place-items: center; background: #fff;
  border-radius: 10px; overflow: hidden; font-size: 34px;
}
.card__thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card__name--live { font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card--live .link-btn { font-size: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: transform .12s, border-color .15s;
}
.card:hover { transform: translateY(-3px); border-color: #384456; }
.card__top { display: flex; align-items: center; gap: 12px; }
.card__emoji {
  font-size: 26px; width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--panel-2); border-radius: 12px; flex-shrink: 0;
}
.card__name { font-size: 14.5px; font-weight: 600; line-height: 1.25; }
.card__niche { font-size: 11px; color: var(--txt-mut); text-transform: uppercase; letter-spacing: .5px; }

.card__prices { display: flex; justify-content: space-between; gap: 8px; }
.pricebox { flex: 1; background: var(--bg-2); border-radius: 10px; padding: 9px 10px; }
.pricebox small { display: block; font-size: 10.5px; color: var(--txt-mut); margin-bottom: 2px; }
.pricebox b { font-size: 14.5px; }
.pricebox--usd b { color: var(--brand-2); }
.pricebox--brl b { color: var(--green); }

.card__meta { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 10.5px; padding: 3px 8px; border-radius: 6px; background: var(--panel-2);
  color: var(--txt-dim); display: inline-flex; gap: 4px; align-items: center;
}
.badge--up { color: var(--green); }
.badge--conc-baixa { color: var(--green); }
.badge--conc-media { color: var(--brand-2); }
.badge--conc-alta { color: #fb923c; }

.card__margin { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.card__margin small { font-size: 11.5px; color: var(--txt-dim); }
.card__margin b { font-size: 16px; }

.card__profit {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 12px; padding-top: 10px; border-top: 1px solid var(--border);
}
.card__profit small { font-size: 11.5px; color: var(--txt-dim); }
.card__profit b { font-size: 15px; }
.card__profit b.pos { color: var(--green); }
.card__profit b.neg { color: var(--red); }

.card .btn { width: 100%; }

.empty { text-align: center; color: var(--txt-mut); padding: 40px; }

/* ---------- Painel de análise (direita) ---------- */
.analise-empty { text-align: center; color: var(--txt-dim); padding: 40px 8px; }
.analise-empty__icon { font-size: 40px; margin-bottom: 14px; }
.analise-empty p { font-size: 13px; line-height: 1.6; }

.verdict {
  border-radius: 12px; padding: 16px; text-align: center; margin-bottom: 16px;
  border: 1px solid var(--border);
}
.verdict__label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: .85; }
.verdict__margin { font-size: 40px; font-weight: 800; line-height: 1.1; margin: 4px 0; }
.verdict__sub { font-size: 13px; }

.hlrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.hl { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.hl small { display: block; font-size: 11px; color: var(--txt-mut); margin-bottom: 3px; }
.hl b { font-size: 17px; }
.hl b.pos { color: var(--green); }
.hl b.neg { color: var(--red); }

.breakdown { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.breakdown__title { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--txt-dim); padding: 12px 14px 6px; font-weight: 700; }
.brow { display: flex; justify-content: space-between; padding: 8px 14px; font-size: 13px; border-top: 1px solid var(--border); }
.brow span { color: var(--txt-dim); }
.brow b { font-variant-numeric: tabular-nums; }
.brow--total { background: var(--panel-2); font-weight: 700; }
.brow--total span, .brow--total b { color: var(--txt); }
.brow--sub span { padding-left: 12px; color: var(--txt-mut); font-size: 12px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.modal__card {
  position: relative; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 18px; width: min(920px, 100%); max-height: 90vh; overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal__head h2 { font-size: 18px; }
.modal__body { display: grid; grid-template-columns: 1fr 340px; overflow-y: auto; }
.modal__col { padding: 20px; }
.modal__col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--txt-dim); margin: 8px 0 12px; }
.modal__col h4:first-child { margin-top: 0; }
.modal__col--result { background: var(--panel); border-left: 1px solid var(--border); }

/* Modal de conexão ML */
.modal__card--narrow { width: min(480px, 100%); }
.ml-step { font-size: 13.5px; color: var(--txt-dim); margin: 14px 0 10px; line-height: 1.5; }
.ml-step:first-child { margin-top: 0; }
.ml-step b { color: var(--brand-2); }
.modal__card--narrow #mlAuthLink { display: inline-block; text-decoration: none; }
.ml-hint { font-size: 12px; color: var(--txt-mut); margin: 10px 0; line-height: 1.5; }
.ml-hint code, .ml-step code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--txt); word-break: break-all; }
.modal__card--narrow #mlConnectBtn { width: 100%; margin-top: 4px; }
.ml-status { font-size: 13px; margin-top: 12px; padding: 8px 10px; border-radius: 8px; }
.ml-status--info { color: var(--txt-dim); }
.ml-status--ok { color: var(--green); background: rgba(34,197,94,.1); }
.ml-status--erro { color: var(--red); background: rgba(239,68,68,.1); }

.modal__product { display: flex; gap: 10px; align-items: center; background: var(--panel); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }
.modal__product span { font-size: 22px; }

.quick-margins { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.quick-margins > span { font-size: 12px; color: var(--txt-dim); }
.tag { background: var(--panel); border: 1px solid var(--border); color: var(--txt); border-radius: 7px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; font-family: var(--font); }
.tag:hover { border-color: var(--brand); }

/* ---------- Mobile helpers ---------- */
.only-mobile { display: none; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
.overlay[hidden] { display: none; }

@media (max-width: 1100px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; width: 300px; z-index: 40; transform: translateX(-100%);
    transition: transform .25s ease; height: 100vh;
  }
  .sidebar--left { left: 0; }
  .sidebar--right { right: 0; left: auto; transform: translateX(100%); border-left: 1px solid var(--border); }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: inline-grid; place-items: center; }
  .modal__body { grid-template-columns: 1fr; }
  .modal__col--result { border-left: none; border-top: 1px solid var(--border); }
}
@media (max-width: 480px) {
  .main { padding: 16px; }
  .topbar h1 { font-size: 19px; }
  .hlrow { grid-template-columns: 1fr; }
}
