/* ============================================================================
   Controle de Perfumes — design system v2
   Claro por padrão (clean/moderno); escuro refinado via [data-theme="dark"]
   (alternador ☀️/🌙/🌗 no topo — js no index.html)
============================================================================ */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #eaecf1;
  --text: #17181d;
  --text-soft: #5d6472;
  --text-faint: #9aa1ad;
  --brand: #6957e8;
  --brand-2: #9a7bff;
  --brand-soft: #efecfd;
  --green: #0e9f6e;   --green-bg: #e6f6ef;
  --amber: #d97706;   --amber-bg: #fdf3e3;
  --blue: #2563eb;    --blue-bg: #eaf1fe;
  --gray: #6b7280;    --gray-bg: #eef0f4;
  --red: #dc2626;     --red-bg: #fdeded;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
  --shadow-lift: 0 2px 4px rgba(16, 24, 40, .06), 0 14px 34px rgba(16, 24, 40, .10);
  --radius: 26px;
  --radius-sm: 16px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #181b21;
  --surface-2: #1f232b;
  --border: #272c36;
  --text: #eef0f4;
  --text-soft: #a6adba;
  --text-faint: #737b89;
  --brand: #8f7bff;
  --brand-2: #b39aff;
  --brand-soft: #262040;
  --green: #46d19a;   --green-bg: #153327;
  --amber: #f0a13a;   --amber-bg: #342811;
  --blue: #7aa5ff;    --blue-bg: #182642;
  --gray: #9aa2af;    --gray-bg: #242933;
  --red: #f37676;     --red-bg: #3a1d1d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .32);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
  transition: background .25s, color .25s;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Layout ---------- */
.wrap { max-width: 1160px; margin: 0 auto; padding: 24px 18px 90px; }

header.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 12px 18px;
  display: flex; align-items: center; gap: 10px;
}
.topbar-inner.sub { padding-top: 0; }
.brandmark { display: flex; align-items: center; gap: 11px; margin-right: auto; min-width: 0; }
.brandmark .dot {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-size: 18px; flex: none;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 35%, transparent);
}
.brandmark h1 { font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Cluster de ícones do app (tema, conta) */
.topicons { display: flex; align-items: center; gap: 8px; flex: none; }

/* Seletor de visão — segmento largura total */
.views {
  display: flex; gap: 4px; width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px;
  box-shadow: var(--shadow);
}
.viewbtn {
  flex: 1; border: 0; background: transparent; color: var(--text-soft);
  padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: .18s;
}
.viewbtn.active { background: var(--brand); color: #fff; }

/* Botões de ícone circulares (tema, conta, ferramentas) */
.iconbtn, .themebtn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 40px; height: 40px; border-radius: 999px; font-size: 16px; flex: none;
  display: grid; place-items: center; box-shadow: var(--shadow); transition: .18s;
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover, .themebtn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.iconbtn.danger { color: var(--red); }
.iconbtn.danger:hover { background: var(--red-bg); border-color: var(--red); }

/* Toolbars */
.toolbar { display: flex; gap: 8px; width: 100%; align-items: center; }
.btn.grow { flex: 1; justify-content: center; }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 17px; border-radius: 999px; font-size: 13.5px; font-weight: 580;
  display: inline-flex; align-items: center; gap: 7px; transition: .18s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn.primary {
  background: var(--brand); color: #fff; border-color: transparent;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 30%, transparent);
}
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #fff); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.btn svg { width: 15px; height: 15px; }
.btn.ai {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border-color: transparent; justify-content: center; width: 100%;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 30%, transparent);
}
.btn.ai:hover { filter: brightness(1.06); color: #fff; }
.btn.ai:disabled { opacity: .65; cursor: wait; transform: none; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 6px 0 22px; }
.kpi {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12.5px; color: var(--text-soft); font-weight: 560; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 25px; font-weight: 720; margin-top: 7px; letter-spacing: -0.03em; }
.kpi .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.kpi .value.pos { color: var(--green); }
.kpi .value.warn { color: var(--amber); }
.kpi .value.brand { color: var(--brand); }

/* ---------- Alertas ---------- */
.alerts { margin: 0 0 22px; display: grid; gap: 8px; }
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--red-bg); border-radius: var(--radius-sm);
  padding: 12px 15px; font-size: 13.5px; color: var(--text);
}
.alert.amber { background: var(--amber-bg); }
.alert .ico { flex: none; font-size: 15px; line-height: 1.4; }
.alert b { font-weight: 650; }
.alert .mini { color: var(--text-soft); }

/* ---------- Controles ---------- */
.controls { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 560;
  transition: .18s;
}
.tab:hover { background: var(--surface-2); }
.tab .cnt { color: var(--text-faint); font-weight: 620; }
.tab.active { background: var(--brand); color: #fff; border-color: transparent; }
.tab.active .cnt { color: rgba(255, 255, 255, .8); }
.search { margin-left: auto; position: relative; min-width: 200px; flex: 1 1 200px; max-width: 340px; }
.search input {
  width: 100%; padding: 10px 16px 10px 38px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--text); font-size: 14px;
  box-shadow: var(--shadow); transition: .18s;
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); }
.selectctl {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 10px 16px; font-size: 13.5px; font-family: inherit;
  box-shadow: var(--shadow);
}
.selectctl:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Tabela (Compras) ---------- */
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
thead th {
  text-align: left; padding: 13px 16px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint); font-weight: 660;
  border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap;
}
thead th.num, td.num { text-align: right; }
thead th .arrow { color: var(--brand); }
tbody tr { border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); transition: background .12s; }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); cursor: pointer; }
tbody tr.alertrow { background: color-mix(in srgb, var(--red-bg) 45%, transparent); }
td { padding: 13px 16px; vertical-align: middle; }
.pname { font-weight: 620; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.pname .ml { color: var(--text-faint); font-weight: 500; font-size: 12px; }
.pest {
  color: var(--amber); font-size: 10.5px; font-weight: 650;
  background: var(--amber-bg); border-radius: 5px; padding: 1px 5px;
}
.orig { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 620;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.recebido  { color: var(--green); background: var(--green-bg); }
.badge.transito  { color: var(--amber); background: var(--amber-bg); }
.badge.sinal     { color: var(--blue);  background: var(--blue-bg); }
.badge.fila      { color: var(--gray);  background: var(--gray-bg); }
.badge.cancelado { color: var(--red);   background: var(--red-bg); }

.dias { font-variant-numeric: tabular-nums; font-weight: 620; }
.dias.hot { color: var(--red); }
.dias.warm { color: var(--amber); }
.saldo0 { color: var(--text-faint); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 48px; text-align: center; color: var(--text-faint); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(13, 15, 20, .40);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; align-items: flex-start; justify-content: center; z-index: 50;
  padding: 26px 14px; overflow-y: auto;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 560px; box-shadow: var(--shadow-lift);
  animation: pop .18s cubic-bezier(.2, .8, .3, 1); margin: auto 0;
}
.modal.wide { max-width: 840px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal header { display: flex; align-items: center; gap: 10px; padding: 18px 22px 14px; }
.modal header h2 { font-size: 17px; margin-right: auto; }
.modal .close {
  border: 0; background: var(--surface-2); color: var(--text-soft);
  font-size: 18px; line-height: 1; width: 32px; height: 32px; border-radius: 999px;
  display: grid; place-items: center; transition: .15s;
}
.modal .close:hover { background: var(--border); color: var(--text); }
.modal .body { padding: 4px 22px 18px; }
.modal .foot { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal .foot .spacer { margin-right: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--text-soft); font-weight: 620; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit;
  transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field textarea { resize: vertical; min-height: 56px; }
.field .hint { font-size: 11px; color: var(--text-faint); }

.detail-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); font-size: 14px;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row .k { color: var(--text-soft); }
.detail-row .v { font-weight: 620; text-align: right; }
.obsbox { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--text-soft); margin-top: 12px; }

/* ---------- Relatório (impressão) ---------- */
.report h2 { font-size: 18px; }
.report .rsub { color: var(--text-soft); font-size: 13px; margin: 4px 0 16px; }
.report .rgroup { margin-bottom: 18px; }
.report .rgroup h3 { font-size: 13px; padding: 7px 11px; border-radius: 8px; margin-bottom: 8px; }
.report .rgroup.hot h3 { background: var(--red-bg); color: var(--red); }
.report .rgroup.warm h3 { background: var(--amber-bg); color: var(--amber); }
.report .rgroup.cool h3 { background: var(--green-bg); color: var(--green); }
.report table { min-width: 0; font-size: 13px; }
.report .rtotal {
  display: flex; justify-content: space-between; background: var(--surface-2);
  padding: 11px 13px; border-radius: var(--radius-sm); font-weight: 650; margin-top: 8px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 560; opacity: 0; pointer-events: none; transition: .25s; z-index: 90;
  box-shadow: var(--shadow-lift);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.foot-note { color: var(--text-faint); font-size: 12px; margin-top: 20px; text-align: center; }

/* ============================================================
   ESTOQUE
============================================================ */
#toolbarEstoque, #view-estoque { display: none; }
body[data-view="estoque"] #toolbarCompras, body[data-view="estoque"] #view-compras { display: none; }
body[data-view="estoque"] #toolbarEstoque { display: flex; }
body[data-view="estoque"] #view-estoque { display: block; }

/* Grid de cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: .2s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.card .thumb {
  aspect-ratio: 4 / 3.4; background: var(--surface-2); display: grid; place-items: center;
  overflow: hidden; position: relative;
}
.card .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .thumb img.prod { object-fit: contain; background: #fff; padding: 10px; }
.card .thumb .ph {
  font-size: 32px; font-weight: 800; letter-spacing: .02em; color: #fff;
  width: 100%; height: 100%; display: grid; place-items: center;
}
.card .cbody { padding: 12px 15px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .cbrand { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); font-weight: 680; }
.card .cname { font-size: 14px; font-weight: 640; line-height: 1.3; letter-spacing: -0.01em; }
.card .cmeta { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-soft); flex-wrap: wrap; }
.card .cfoot { margin-top: auto; padding-top: 9px; }

.chip {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2);
  color: var(--text-soft); white-space: nowrap;
}
.chip.fam { background: var(--brand-soft); color: var(--brand); }
.chip.status-lacrado { color: var(--blue); background: var(--blue-bg); }
.chip.status-em-uso { color: var(--green); background: var(--green-bg); }
.chip.status-vazio { color: var(--gray); background: var(--gray-bg); }

/* Barra de nível do frasco */
.level { display: flex; align-items: center; gap: 8px; }
.level .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.level .fill { height: 100%; border-radius: 999px; background: var(--green); transition: width .3s; }
.level .fill.mid { background: var(--amber); }
.level .fill.low { background: var(--red); }
.level .pct { font-size: 11px; font-weight: 650; color: var(--text-soft); min-width: 32px; text-align: right; }

/* Pirâmide olfativa */
.pyr { display: grid; gap: 10px; margin-top: 10px; }
.pyr .tier { background: var(--surface-2); border-radius: var(--radius-sm); padding: 11px 13px; }
.pyr .tlabel {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: var(--text-faint); margin-bottom: 7px; display: flex; align-items: center; gap: 6px;
}
.pyr .notes { display: flex; flex-wrap: wrap; gap: 5px; }
.pyr .note {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.pyr .tier.topo    .tlabel { color: var(--amber); }
.pyr .tier.coracao .tlabel { color: var(--brand); }
.pyr .tier.base    .tlabel { color: var(--green); }

.accords { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.accords .chip { text-transform: capitalize; }

.extlinks { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.extlinks a {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  font-size: 12.5px; font-weight: 620; color: var(--brand);
  background: var(--brand-soft); border-radius: 10px; padding: 8px 13px; transition: .15s;
}
.extlinks a:hover { filter: brightness(.96); }

/* Foto no modal */
.dphoto { width: 100%; max-height: 250px; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 12px; }
.dphoto.prodimg { background: #fff; padding: 10px; }

/* Match hint no formulário */
.matchhint { font-size: 12px; margin-top: 4px; }
.matchhint.ok { color: var(--green); }
.matchhint.none { color: var(--text-faint); }

/* Autocomplete do banco de 110 mil perfumes */
.field { position: relative; }
.acp {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift); max-height: 320px; overflow-y: auto; margin-top: 4px;
}
.acp-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px; cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.acp-item:last-child { border-bottom: 0; }
.acp-item:hover { background: var(--surface-2); }
.acp-item img, .acp-noimg {
  width: 34px; height: 44px; object-fit: contain; background: #fff; border-radius: 6px;
  flex: none; display: grid; place-items: center; font-size: 18px;
}
.acp-tx { min-width: 0; }
.acp-nm { font-size: 13.5px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acp-br { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acp-msg { padding: 12px 14px; font-size: 12.5px; color: var(--text-faint); }

/* Range de nível */
.rangewrap { display: flex; align-items: center; gap: 10px; }
.rangewrap input[type="range"] { flex: 1; accent-color: var(--brand); }
.rangewrap output { font-size: 13px; font-weight: 650; min-width: 42px; text-align: right; }

/* Match % e avaliação */
.matchpct {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-size: 11px; font-weight: 720; padding: 3px 8px; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.matchpct.inl { position: static; font-size: 12px; vertical-align: middle; margin-left: 6px; }
.lovemark { position: absolute; top: 8px; left: 8px; z-index: 2; font-size: 15px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }

.raterow { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 2px 0 12px; }
.ratelabel { font-size: 12.5px; color: var(--text-soft); font-weight: 600; }
.rate {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: .15s;
}
.rate:hover { background: var(--surface); border-color: var(--brand); }
.rate.on { background: var(--brand); border-color: transparent; color: #fff; }

/* Similares */
.simsec { margin-top: 16px; }
.simh {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: var(--text-faint); margin: 14px 0 8px;
}
.simcard {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px;
  background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 7px;
}
.simcard img { width: 40px; height: 52px; object-fit: contain; background: #fff; border-radius: 7px; flex: none; }
.simtx { min-width: 0; flex: 1; }
.simnm { font-size: 13.5px; font-weight: 640; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.simbr { font-size: 11.5px; color: var(--text-faint); }
.simmeta { font-size: 11.5px; color: var(--brand); font-weight: 620; margin-top: 1px; }
.simadd { flex: none; padding: 6px 10px; }

/* Painel de notas */
.notas-panel {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px 18px 16px; margin-bottom: 16px;
}
.nchips { display: flex; flex-wrap: wrap; gap: 7px; }
.nchip { cursor: pointer; border: 1px solid var(--border); transition: .15s; font-size: 12px; padding: 6px 11px; }
.nchip:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.nchip b { margin-left: 3px; color: var(--text-faint); font-weight: 650; }
.nchip.fam { border-color: transparent; }

/* Barras do perfil olfativo */
.pfrow { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.pfemoji { flex: none; width: 22px; text-align: center; }
.pfnome { flex: none; width: 138px; font-size: 13px; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pfbar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.pffill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.pffill.neg { background: var(--red); }
.pfpct { flex: none; width: 38px; text-align: right; font-size: 12px; font-weight: 650; color: var(--text-soft); }

.empty-inv {
  grid-column: 1 / -1; text-align: center; padding: 64px 20px; color: var(--text-faint);
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.empty-inv .big { font-size: 42px; margin-bottom: 10px; }
.empty-inv p { margin: 6px 0 18px; }

/* ---------- Responsivo ---------- */
@media (max-width: 780px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .search { max-width: none; }
  .brandmark h1 { font-size: 15px; }
}
@media (max-width: 640px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 11px; }
  .card .thumb { aspect-ratio: 1 / 1; }
}
@media (max-width: 460px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px 15px; }
  .kpi .value { font-size: 21px; }
}

/* ---------- Insights da coleção ---------- */
.insights { display: flex; flex-direction: column; gap: 8px; margin: 0 0 22px; }
.insight {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 12px 15px; box-shadow: var(--shadow);
  border-left: 3px solid var(--brand);
}
.insight .ins-e { font-size: 19px; flex: none; line-height: 1; }
.insight .ins-t { font-size: 13.5px; color: var(--text-soft); }
.insight .ins-t b { color: var(--text); font-weight: 680; }

/* ---------- Relatório v2 ---------- */
.rcover {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border-radius: var(--radius-sm); padding: 18px 20px; margin-bottom: 16px;
}
.rcover-t { font-size: 18px; font-weight: 720; letter-spacing: -0.01em; }
.rcover-s { font-size: 12.5px; opacity: .85; margin-top: 3px; }
.rkpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.rkpi { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.rk-label { font-size: 11.5px; color: var(--text-soft); font-weight: 600; }
.rk-val { font-size: 19px; font-weight: 720; letter-spacing: -0.02em; }
.rkpi.brand .rk-val { color: var(--brand); }
.rkpi.amber .rk-val { color: var(--amber); }
.rkpi.green .rk-val { color: var(--green); }
.rk-sub { font-size: 11px; color: var(--text-faint); }
.rsection { margin-bottom: 20px; }
.rsection h3 { font-size: 14px; margin-bottom: 10px; }
/* gastos por mês */
.mchart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 16px; }
.mcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.mbar { width: 100%; max-width: 42px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.mval { font-size: 10.5px; font-weight: 650; color: var(--text-soft); margin-bottom: 3px; }
.mlab { font-size: 10px; color: var(--text-faint); margin-top: 5px; white-space: nowrap; }
/* marcas */
.bchart { display: flex; flex-direction: column; gap: 7px; }
.brow { display: flex; align-items: center; gap: 10px; }
.blab { flex: 0 0 150px; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; color: var(--text-soft); }
.btrack { flex: 1; height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bfill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bval { flex: 0 0 52px; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
/* barras de espera */
.wrow { padding: 9px 0; border-bottom: 1px dashed var(--border); }
.wrow:last-child { border-bottom: 0; }
.wtop { font-size: 13.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wdias { margin-left: auto; font-weight: 720; font-size: 12.5px; padding: 1px 9px; border-radius: 999px; }
.wdias.hot { background: var(--red-bg); color: var(--red); }
.wdias.warm { background: var(--amber-bg); color: var(--amber); }
.wdias.cool { background: var(--green-bg); color: var(--green); }
.wtrack { position: relative; height: 9px; background: var(--surface-2); border-radius: 999px; margin: 6px 0 5px; overflow: visible; }
.wfill { height: 100%; border-radius: 999px; }
.wfill.hot { background: linear-gradient(90deg, var(--amber), var(--red)); }
.wfill.warm { background: linear-gradient(90deg, var(--green), var(--amber)); }
.wfill.cool { background: var(--green); }
.wavg { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-faint); border-radius: 2px; }
.wsub { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-soft); }

/* ---------- Comprado para / importação seletiva ---------- */
.pdest {
  font-size: 11px; font-weight: 650; color: var(--amber);
  background: var(--amber-bg); border-radius: 999px; padding: 2px 8px; margin-left: 7px;
  white-space: nowrap;
}
.implist { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }
.improw {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 13px;
}
.improw input { width: 17px; height: 17px; accent-color: var(--brand); flex: none; }
.improw .impname { flex: 1; font-size: 14px; }
.improw .chip { flex: none; }

/* ---------- Unidades ---------- */
.qtdctl { display: inline-flex; align-items: center; gap: 10px; }
.qtdctl b { min-width: 18px; text-align: center; font-size: 15px; }
.qtdctl .rate { width: 30px; height: 30px; padding: 0; justify-content: center; font-size: 16px; line-height: 1; }
.chip.qtdchip { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.rate.abrir { background: var(--brand-soft); color: var(--brand); border-color: transparent; font-weight: 650; }

/* ---------- Login / contas ---------- */
html.auth-lock { overflow: hidden; }
/* sem login, NADA do app fica visível/rolável atrás da tela de entrada */
html.auth-lock body > *:not(.auth-overlay) { display: none !important; }
.auth-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.auth-card {
  width: 100%; max-width: 380px; margin: auto;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 30px 26px 26px; text-align: center;
}
.auth-form[hidden] { display: none !important; } /* aba inativa some de verdade */
.auth-logo {
  width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.auth-card h2 { font-size: 19px; }
.auth-sub { margin: 6px 0 16px; color: var(--text-soft); font-size: 13.5px; }
.auth-aviso {
  background: var(--amber-bg); color: var(--amber);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; margin-bottom: 12px;
}
.auth-tabs {
  display: flex; gap: 6px; background: var(--surface-2);
  border-radius: 999px; padding: 4px; margin-bottom: 16px;
}
.auth-tabs button {
  flex: 1; border: 0; background: none; color: var(--text-soft);
  padding: 8px 0; border-radius: 999px; font-size: 14px; font-weight: 600;
}
.auth-tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-form label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); display: flex; flex-direction: column; gap: 5px; }
.auth-form input {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  padding: 10px 12px; font-size: 15px; font-family: inherit; outline: none;
}
.auth-form input:focus { border-color: var(--brand); }
.auth-senha { position: relative; display: block; }
.auth-senha input { width: 100%; padding-right: 44px; }
.auth-olho {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; font-size: 17px; line-height: 1;
  padding: 6px; color: var(--text-faint);
}
.auth-hint { font-weight: 400; color: var(--text-faint); font-size: 12px; }
.auth-btn {
  margin-top: 4px; border: 0; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  padding: 12px; font-size: 15px; font-weight: 650;
}
.auth-btn:disabled { opacity: .6; cursor: default; }
.auth-btn.ghost { background: var(--surface-2); color: var(--text); }
.auth-link {
  border: 0; background: none; color: var(--brand); font-size: 13px; font-weight: 600;
  padding: 4px; margin-top: 2px; align-self: center;
}
.auth-erro {
  margin-top: 12px; background: var(--red-bg); color: var(--red);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px;
}
.auth-off { margin-top: 12px; color: var(--text-faint); font-size: 12.5px; }
.auth-off .auth-btn { width: 100%; margin-top: 6px; }
.auth-msg {
  margin-top: 8px; background: var(--brand-soft); color: var(--text);
  border-radius: var(--radius-sm); padding: 14px 14px 10px; font-size: 13.5px; line-height: 1.45;
}
.auth-msg p { margin: 0 0 8px; }
.auth-msg .auth-link { display: block; }
.themebtn.conta { margin-left: 4px; }

/* ---------- Impressão ---------- */
@media print {
  header.topbar, .kpis, .alerts, .controls, .table-wrap, .foot-note, .toast { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .overlay { position: static; display: block !important; background: none; padding: 0; overflow: visible; backdrop-filter: none; }
  .overlay:not(.printing) { display: none !important; }
  .modal { box-shadow: none; border: 0; max-width: 100%; animation: none; }
  .modal header .close, .modal .foot { display: none !important; }
  .report2 .rcover, .report2 .rkpi, .report2 .mbar, .report2 .bfill, .report2 .btrack,
  .report2 .wfill, .report2 .wtrack, .report2 .wdias, .report2 .wavg {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .report2 .rsection, .report2 .rkpis, .report2 .wrow { break-inside: avoid; }
  .report2 .mchart { height: 110px; }
  .report .rgroup.hot h3 { background: #fde8e8 !important; color: #b91c1c !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report .rgroup.warm h3 { background: #fdf1dd !important; color: #b45309 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report .rgroup.cool h3 { background: #e7f6ec !important; color: #15803d !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  thead th { background: #f3f4f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
