@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --accent: #FFC72C;
  --bg: #F4F5F7;
  --ink: #171A21;
  --muted: #6B7280;
  --border: #E4E6EB;
  --sidebar: #121212;
  --sidebar-muted: #A3A3A3;
  --green: #167A43;
  --green-bg: #1F9D55;
  --orange: #B25900;
  --orange-bg: #E8952E;
  --red: #C22A2A;
  --red-bg: #E15C53;
  --sidebar-w: 200px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { text-decoration: none; color: inherit; }

h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 14px; }
h3 { font-size: 12px; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  transition: width .15s ease;
}
.sidebar.collapsed { padding: 20px 10px; }

.sidebar-toggle {
  position: absolute; top: 22px; right: -14px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--sidebar); color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 5; padding: 0;
}
.sidebar-toggle:hover { background: #FFD65C; }
.sidebar-toggle svg { transition: transform .15s ease; flex: 0 0 auto; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: #fff;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: var(--ink);
  padding: 5px;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 13px; color: #F4F5F7; white-space: nowrap; }
.brand-sub { font-size: 9px; color: var(--sidebar-muted); white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.navitem {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 7px;
  font-size: 12.5px; font-weight: 500; color: #C7CBD6; white-space: nowrap;
}
a.navitem:hover { background: rgba(255,255,255,.07); }
.navitem.active { background: var(--accent); color: var(--ink); font-weight: 700; }
.navitem svg { flex: 0 0 auto; }
.sidebar.collapsed .navitem { justify-content: center; padding: 9px; }

/* Escondido quando a sidebar está retraída — só os ícones ficam visíveis. */
.sidebar.collapsed .brand-text,
.sidebar.collapsed .navitem-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-footer-info,
.sidebar.collapsed .navitem .em-breve { display: none; }
.sidebar.collapsed .footer-sidebar { align-items: center; }
.sidebar.collapsed #btn-logout { text-align: center; padding-top: 9px; }

.main { flex: 1 1 auto; min-width: 0; padding: 22px 28px; display: flex; flex-direction: column; gap: 16px; position: relative; }

/* Indicador de carregamento — aparece sobre o conteúdo enquanto os dados de
   um filtro/página estão sendo buscados (consultas ficaram mais pesadas com
   o histórico completo importado). */
.overlay-carregando {
  position: fixed; inset: 0; left: var(--sidebar-w); background: rgba(244,245,247,.7); backdrop-filter: blur(1px);
  display: none; align-items: center; justify-content: center; z-index: 50; transition: left .15s ease;
}
.overlay-carregando.visivel { display: flex; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: girar-spinner .7s linear infinite; }
@keyframes girar-spinner { to { transform: rotate(360deg); } }

.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pagehead h1 { font-size: 20px; }
.pagehead p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .caption { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-family: 'Space Grotesk', sans-serif; font-size: 23px; font-weight: 700; }
.kpi .delta { font-size: 12.5px; font-weight: 700; }
.up { color: var(--green); }
.down { color: var(--red); }

select, input[type=text], input[type=password], input[type=number], input[type=month] {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 600; color: #4B5160;
  border: 1px solid #D8DBE2; border-radius: 7px; padding: 7px 10px; background: #fff;
}

/* Dropdown de multi-seleção (filtros de Loja / Centro de Consumo): fechado
   por padrão feito um <select> comum, abre um painel com checkboxes. */
.multiselect { position: relative; display: inline-block; }
.multiselect-btn {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 600; color: #4B5160;
  border: 1px solid #D8DBE2; border-radius: 7px; padding: 7px 10px; background: #fff;
  min-width: 150px; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  cursor: pointer;
}
.multiselect-btn::after { content: '▾'; color: var(--muted); font-size: 10px; }
.multiselect-btn.tem-selecao { border-color: var(--accent); color: var(--ink); }
.multiselect-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 220px; max-height: 260px;
  overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23,26,33,.12); padding: 6px;
}
.multiselect-panel[hidden] { display: none; }
.multiselect-item {
  display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: #4B5160;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.multiselect-item:hover { background: var(--bg); }
.multiselect-item input { accent-color: var(--accent); cursor: pointer; }
.multiselect-clear {
  display: block; width: 100%; text-align: left; font-size: 11px; font-weight: 700; color: var(--accent);
  background: none; border: none; border-top: 1px solid var(--border); margin-top: 4px; padding: 6px 8px 2px; cursor: pointer;
}

button {
  font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 12px; cursor: pointer;
  border-radius: 7px; padding: 8px 14px; border: 1px solid var(--accent); background: var(--accent); color: #171A21;
}
button.secondary { background: #fff; color: var(--ink); border-color: var(--border); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.badge.ok { background: rgba(31,157,85,.12); color: var(--green); }
.badge.pend { background: rgba(232,149,46,.15); color: var(--orange); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar); }
.login-card { width: 320px; background: #fff; border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }

.msg { font-size: 12px; padding: 10px 12px; border-radius: 8px; }
.msg.error { background: rgba(194,42,42,.08); color: var(--red); }
.msg.ok { background: rgba(31,157,85,.08); color: var(--green); }

.dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted);
  font-size: 13px; cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); color: #8A6D00; background: rgba(255,199,44,.10); }

.pill-select { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-select button { background: #fff; border-color: var(--border); color: var(--ink); font-weight: 600; padding: 6px 12px; }
.pill-select button.selected { background: var(--accent); border-color: var(--accent); color: var(--ink); }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }

/* Cards de linha de produto (Resumo) */
.pcard { padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pname { display: flex; align-items: center; gap: 6px; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 14px; color: var(--ink); }
.pstatus { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pstatus .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.pval { font-family: 'Space Grotesk', sans-serif; font-size: 19px; font-weight: 700; }
.pgrowth { font-size: 11.5px; font-weight: 700; }
.pbar-track { width: 100%; height: 6px; border-radius: 3px; background: #EEF0F3; overflow: hidden; }
.pbar-fill { height: 100%; border-radius: 3px; }
.pmeta-row { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }

/* Donut de participação */
.donut-row { display: flex; align-items: center; gap: 14px; }
.donut { width: 72px; height: 72px; border-radius: 50%; flex: 0 0 auto; }
.legend { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.legend-item { display: flex; align-items: center; justify-content: space-between; font-size: 12px; gap: 8px; }
.legend-item .sw { width: 7px; height: 7px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.legend-item .lbl { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chart-card { padding: 11px 13px; display: flex; flex-direction: column; gap: 5px; }
.chart-title { display: flex; align-items: center; gap: 6px; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 12.5px; }
.chart-title .sw { width: 6px; height: 6px; border-radius: 2px; display: inline-block; }
.chart-foot { font-size: 10.5px; color: var(--muted); }
