/* ============================================================
   SourcingHub — Design System
   Sidebar escura fixa · badges coloridos · rounded-2xl · charts vívidos
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --border: #e7eaf3;
  --text: #0f172a;
  --muted: #64748b;

  --sidebar: #0b1120;
  --sidebar-2: #131c31;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;

  --primary: #6366f1;
  --primary-600: #4f46e5;
  --primary-soft: #eef2ff;

  /* paleta vívida p/ gráficos e badges */
  --c-violet: #8b5cf6;
  --c-indigo: #6366f1;
  --c-sky: #0ea5e9;
  --c-emerald: #10b981;
  --c-amber: #f59e0b;
  --c-rose: #f43f5e;
  --c-cyan: #06b6d4;
  --c-pink: #ec4899;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 4px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }
.muted { color: var(--muted); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 20px; }
.brand__logo {
  width: 42px; height: 42px; border-radius: 13px;
  background: linear-gradient(135deg, var(--c-violet), var(--c-indigo));
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 15px;
  box-shadow: 0 6px 18px rgba(99,102,241,.45);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__text strong { color: #fff; font-size: 15px; }
.brand__text span { color: var(--sidebar-muted); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; overflow-y: auto; }
.nav__sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 12px; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: 0; border-radius: 12px;
  background: transparent; color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  text-align: left; width: 100%; transition: .15s;
}
.nav__item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav__item.is-active { background: rgba(99,102,241,.16); color: #fff; }
.nav__icon {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; font-size: 13px; color: #fff; flex-shrink: 0;
}
.nav__icon--violet { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }
.nav__icon--sky    { background: linear-gradient(135deg,#38bdf8,#0284c7); }
.nav__icon--emerald{ background: linear-gradient(135deg,#34d399,#059669); }
.nav__icon--amber  { background: linear-gradient(135deg,#fbbf24,#d97706); }
.nav__icon--rose   { background: linear-gradient(135deg,#fb7185,#e11d48); }
.nav__icon--slate  { background: linear-gradient(135deg,#94a3b8,#475569); }
.nav__icon--cyan   { background: linear-gradient(135deg,#22d3ee,#0891b2); }

.sidebar__footer { margin-top: auto; padding-top: 16px; }
.api-status {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.05); border-radius: 12px;
  padding: 10px 12px; font-size: 12px; color: var(--sidebar-text);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot--demo { background: var(--c-amber); box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.dot--live { background: var(--c-emerald); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 20px 28px; background: var(--bg);
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
.topbar p { margin: 2px 0 0; font-size: 13px; }
.topbar__actions { display: flex; align-items: center; gap: 12px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 12px; width: 300px;
}
.search span { color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 13px; color: var(--text); }

.content { padding: 24px 28px 48px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 11px; padding: 9px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-600); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.btn--block { width: 100%; justify-content: center; text-align: center; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.grid--kpi { grid-template-columns: repeat(4, 1fr); }
.grid--2 { grid-template-columns: 1.4fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .grid--kpi { grid-template-columns: repeat(2,1fr);} .grid--2,.grid--3{grid-template-columns:1fr;} }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card__head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card__head p { margin: 2px 0 0; font-size: 12px; }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 14px; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__badge {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  font-size: 18px; color: #fff;
}
.b-violet { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }
.b-sky    { background: linear-gradient(135deg,#38bdf8,#0284c7); }
.b-emerald{ background: linear-gradient(135deg,#34d399,#059669); }
.b-amber  { background: linear-gradient(135deg,#fbbf24,#d97706); }
.b-rose   { background: linear-gradient(135deg,#fb7185,#e11d48); }
.b-cyan   { background: linear-gradient(135deg,#22d3ee,#0891b2); }
.kpi__value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi__label { font-size: 12.5px; color: var(--muted); }
.trend { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.trend--up { color: #047857; background: #d1fae5; }
.trend--down { color: #be123c; background: #ffe4e6; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }

.prod { display: flex; align-items: center; gap: 11px; }
.prod__thumb {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 18px; background: var(--surface-2);
}
.prod__name { font-weight: 600; }
.prod__sub { font-size: 11.5px; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill--green { background: #d1fae5; color: #047857; }
.pill--amber { background: #fef3c7; color: #b45309; }
.pill--red { background: #ffe4e6; color: #be123c; }
.pill--sky { background: #e0f2fe; color: #0369a1; }
.pill--violet { background: #ede9fe; color: #6d28d9; }
.pill--slate { background: #eef2f7; color: #475569; }

.score { display: inline-flex; align-items: center; gap: 8px; }
.score__bar { width: 60px; height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.score__fill { height: 100%; border-radius: 999px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* channel logos */
.chan { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.chan__dot { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- Bars chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars__bar { width: 100%; border-radius: 8px 8px 4px 4px; transition: .3s; }
.bars__x { font-size: 11px; color: var(--muted); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Calculator ---------- */
.calc { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px){ .calc { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 11px; font-size: 13.5px; background: var(--surface); color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fx-field .flex { gap: 8px; }
.fx-field .flex input { flex: 1; }
.fx-field label { display: inline-block; }

.result-line { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.result-line:last-child { border-bottom: 0; }
.result-line strong { font-weight: 700; }
.result-total { font-size: 22px; font-weight: 800; }

.mk-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.mk-row:last-child { border-bottom: 0; }
.mk-check { display: flex; align-items: center; gap: 10px; }
.mk-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.mk-region { display: flex; align-items: center; gap: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; color: var(--muted); margin: 16px 0 6px; }
.mk-region:first-of-type { margin-top: 4px; }
.cflag {
  display: inline-grid; place-items: center; width: 26px; height: 18px; border-radius: 5px;
  color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .3px; text-transform: none;
  flex-shrink: 0; box-shadow: 0 1px 3px rgba(15,23,42,.25);
}

.profit-good { color: #047857; }
.profit-bad { color: #be123c; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 24px;
}
.modal h3 { margin: 0 0 4px; font-size: 17px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow-lg); min-width: 260px;
  animation: slidein .25s ease; font-size: 13px;
}
.toast--ok { border-left-color: var(--c-emerald); }
.toast--warn { border-left-color: var(--c-amber); }
.toast--err { border-left-color: var(--c-rose); }
.toast strong { display: block; margin-bottom: 2px; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Wizard (iFlow) ---------- */
.wiz__steps {
  display: flex; align-items: center; gap: 6px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); overflow-x: auto;
}
.wiz__step { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; cursor: default; white-space: nowrap; opacity: .55; }
.wiz__step.is-current, .wiz__step.is-done { opacity: 1; }
.wiz__step.is-done, .wiz__step.is-current { cursor: pointer; }
.wiz__num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
  background: var(--surface-2); color: var(--muted); border: 2px solid var(--border);
}
.wiz__step.is-current .wiz__num { background: var(--primary); color: #fff; border-color: var(--primary); }
.wiz__step.is-done .wiz__num { background: var(--c-emerald); color: #fff; border-color: var(--c-emerald); }
.wiz__t { font-size: 13px; font-weight: 700; }
.wiz__d { font-size: 11px; color: var(--muted); }
.wiz__sep { flex: 1; min-width: 16px; height: 2px; background: var(--border); border-radius: 2px; }
.wiz__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}

.sup-search { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.sup-search .field { flex: 1; min-width: 120px; }
.sup-search .btn { height: 40px; }
@media (max-width: 720px) { .sup-search .field { flex: 1 1 45%; } }

/* barra de posicionamento de preço vs concorrentes */
.pricebar { position: relative; height: 22px; margin: 6px 0 2px; }
.pricebar__track { position: absolute; top: 9px; left: 0; right: 0; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #f59e0b, #f43f5e); }
.pricebar__mine { position: absolute; top: 0; transform: translateX(-50%); }
.pricebar__mine::before { content: ''; display: block; width: 3px; height: 22px; background: var(--text); margin: 0 auto; border-radius: 2px; }
.pricebar__mine span { position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; color: var(--text); white-space: nowrap; }

.pick { cursor: pointer; }
.pick:hover { background: var(--surface-2); }
.pick--active { background: var(--primary-soft) !important; box-shadow: inset 3px 0 0 var(--primary); }

/* ---------- Timeline E2E ---------- */
.timeline { display: flex; flex-direction: column; }
.tstage { display: grid; grid-template-columns: 40px 1fr; gap: 14px; }
.tstage__rail { display: flex; flex-direction: column; align-items: center; }
.tstage__dot {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--border); background: #fff; font-weight: 800; font-size: 13px; color: var(--text);
  z-index: 1; flex-shrink: 0;
}
.tstage.is-done .tstage__dot { color: #fff; }
.tstage__line { flex: 1; width: 2px; background: var(--border); margin: 2px 0; min-height: 20px; }
.tstage.is-done .tstage__line { background: var(--c-emerald); }
.tstage__card { margin-bottom: 16px; }
.tstage.is-current .tstage__card { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.acts { display: flex; flex-direction: column; gap: 8px; }
.act {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); transition: .15s;
}
.act--row { align-items: center; }
.act--row .act__body { flex: 1; min-width: 0; }
.act:hover { background: var(--surface-2); }
.act input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--c-emerald); flex-shrink: 0; cursor: pointer; }
.act__label { font-weight: 600; font-size: 13.5px; }
.act--done .act__label { color: var(--text); }
.act__meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.act__meta .pill { font-size: 11px; padding: 3px 8px; }
.act__status {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0; border: 2px solid;
}
.act__status.verified { color: #047857; border-color: #6ee7b7; background: #d1fae5; }
.act__status.action   { color: #b45309; border-color: #fcd34d; background: #fef3c7; }
.act__status.blocked  { color: #be123c; border-color: #fda4af; background: #ffe4e6; }
.act__status.pending  { color: #94a3b8; border-color: #e2e8f0; background: #fff; }
.act__ref { font-size: 12px; margin-top: 6px; font-weight: 600; }
.act__ref.verified { color: #047857; }
.act__ref.action, .act__ref.blocked { color: #b45309; }

.section-title { font-size: 14px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.hint { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 11px; padding: 12px 14px; }
.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; background: var(--sidebar); color: #e2e8f0; padding: 14px 16px; border-radius: 12px; overflow-x: auto; white-space: pre; }

.row-actions { display: flex; gap: 6px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 18px; }
.big-num { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
