/* Central de Vendas — NS Distribuidora
   Sistema de componentes novo, compartilhado pelo módulo do vendedor (index.php)
   e pelo Portal do Cliente (cliente/index.php). Carrega depois de assets/app.css,
   que fornece somente tokens, reset, botões, campos de formulário e toast. */

/* ---------- Marca (SVG inline — recriação da logo, estrela dourada + monograma) ---------- */
.cv-glyph { display: inline-flex; flex: 0 0 auto; }
.cv-glyph svg { display: block; width: 30px; height: 30px; }
.cv-glyph-lg svg { width: 52px; height: 52px; }

/* ---------- Tela de acesso ---------- */
.cv-auth {
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 26px; padding: 32px 20px;
    background:
        radial-gradient(circle at 82% 8%, rgba(30, 76, 130, .35), transparent 45%),
        linear-gradient(175deg, var(--navy) 0%, #081422 100%);
}
.cv-auth-card { width: min(440px, 100%); padding: 38px 34px 32px; background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.cv-auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.cv-auth-brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.cv-auth-brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.cv-auth-card h1 { margin: 0 0 6px; font-size: 25px; letter-spacing: -.03em; }
.cv-auth-sub { margin: 0 0 26px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.cv-auth-card form { display: grid; gap: 16px; }
.cv-auth-foot { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line-soft); color: var(--muted-2); font-size: 11.5px; line-height: 1.5; }
.cv-auth-side { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 440px; }
.cv-auth-side span { padding: 8px 14px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .05); border-radius: 99px; color: #cbd8e2; font-size: 12px; font-weight: 600; }

/* ---------- Cabeçalho ---------- */
.cv-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.cv-header {
    position: sticky; top: 0; z-index: 16; height: 60px; flex: 0 0 auto;
    display: flex; align-items: center; gap: 18px;
    padding: 0 20px; background: var(--navy); color: #fff;
    box-shadow: 0 3px 14px rgba(8, 18, 30, .22);
}
.cv-header-brand { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.cv-header-brand strong { display: block; font-size: 13.5px; line-height: 1.2; }
.cv-header-brand small { display: block; color: #8ea2b3; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.cv-header-search { flex: 1 1 auto; min-width: 0; max-width: 640px; margin: 0 auto; }
.cv-header-search input {
    height: 38px; padding-right: 62px; border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .07); color: #fff; box-shadow: none;
}
.cv-header-search input::placeholder { color: #90a3b3; }
.cv-header-search input:focus { background: var(--white); color: var(--ink); }
.cv-header-search input:focus::placeholder { color: #98a3ac; }
.cv-header-search span { color: #9fb2c1; }
.cv-header-search input:focus + .cv-search-kbd { display: none; }

/* Em tela estreita o campo de busca é movido (via JS) do cabeçalho pra
   este slot, logo abaixo do título do catálogo e acima dos filtros de
   categoria — some sozinho (:empty) quando o campo está no cabeçalho. */
#slot-busca-mobile:empty { display: none; }
#slot-busca-mobile { display: flex; justify-content: center; }
#slot-busca-mobile .cv-header-search { width: 100%; max-width: 480px; margin: 0; }
#slot-busca-mobile .cv-header-search input {
    height: 46px; padding-right: 40px; border: 1.5px solid var(--line);
    background: var(--white); color: var(--ink); box-shadow: var(--shadow-xs); font-size: 16px;
}
#slot-busca-mobile .cv-header-search input::placeholder { color: #90a3b3; }
#slot-busca-mobile .cv-header-search span { color: #8894a0; }
#slot-busca-mobile .cv-search-kbd { display: none; }
.cv-search-kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    padding: 3px 7px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px;
    color: #b7c5d0; background: rgba(255, 255, 255, .06);
    font: 700 10.5px/1 var(--font, inherit); letter-spacing: .02em; pointer-events: none;
}
.cv-header-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.cv-header-actions .btn { color: #d8e2ea; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .09); }
.cv-header-actions .btn:hover { background: rgba(255, 255, 255, .16); }
.cv-header-actions .btn.is-admin { color: #d7f4e8; background: rgba(31, 125, 92, .35); border-color: rgba(140, 218, 191, .25); }
.cv-header-actions .btn.is-admin:hover { background: rgba(31, 125, 92, .52); }
.cv-header-user { display: flex; align-items: center; gap: 9px; padding-left: 8px; margin-left: 4px; border-left: 1px solid rgba(255, 255, 255, .14); }
.cv-header-avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; color: var(--navy); font-weight: 800; font-size: 12.5px; background: var(--gold); }
.cv-header-user-name { display: block; max-width: 130px; overflow: hidden; font-size: 12.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

.cv-header-stat {
    display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
    gap: 1px; padding: 4px 12px; flex: 0 0 auto; white-space: nowrap;
    border-radius: var(--radius-md); background: rgba(232, 163, 23, .12); border: 1px solid rgba(232, 163, 23, .28);
}
.cv-header-stat-label { font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #cdd9e2; }
.cv-header-stat-value { font-size: 14px; font-weight: 800; color: var(--gold); }

/* ---------- Barra de contexto ---------- */
.cv-toolbar {
    position: sticky; top: 60px; z-index: 14; flex: 0 0 auto;
    display: flex; align-items: stretch; gap: 10px;
    padding: 12px 20px; background: var(--navy-2); border-bottom: 1px solid rgba(255, 255, 255, .07);
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.cv-toolbar::-webkit-scrollbar { display: none; }
.cv-chip {
    flex: 0 0 auto; min-width: 168px; display: flex; flex-direction: column; justify-content: center; gap: 2px;
    padding: 8px 14px; border: 1.5px solid rgba(255, 255, 255, .12); border-radius: var(--radius-md);
    color: #fff; background: rgba(255, 255, 255, .05); text-align: left;
    transition: border-color var(--fast), background-color var(--fast), box-shadow var(--fast);
}
button.cv-chip:hover { background: rgba(255, 255, 255, .1); }
.cv-chip-label { font-size: 9.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #9fb2c1; }
.cv-chip strong { overflow: hidden; font-size: 13.5px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.cv-chip small { overflow: hidden; color: #b7c5d0; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.cv-chip.needs-attention { border-color: var(--gold); background: rgba(232, 163, 23, .16); box-shadow: 0 0 0 3px rgba(232, 163, 23, .18); }
.cv-chip.needs-attention .cv-chip-label { color: #ffd98a; }
.cv-chip:disabled { cursor: default; opacity: .85; }
.cv-chip.cv-chip-status { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; border-color: rgba(232, 163, 23, .5); background: rgba(232, 163, 23, .14); }
.cv-chip.cv-chip-status .cv-chip-cancel { flex: 0 0 auto; padding: 5px 10px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 7px; color: #fff; background: transparent; font-size: 11px; font-weight: 700; }
.cv-chip.cv-chip-status .cv-chip-cancel:hover { background: rgba(255, 255, 255, .12); }
.cv-chip.cv-chip-toggle { justify-content: center; cursor: pointer; }
.cv-chip-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cv-chip-toggle-row > span:first-child { overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.cv-switch { position: relative; flex: 0 0 auto; display: inline-block; width: 34px; height: 20px; }
.cv-switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.cv-switch i {
    position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 255, 255, .22);
    transition: background-color var(--fast); pointer-events: none;
}
.cv-switch i::before {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(8, 18, 30, .35); transition: transform var(--fast);
}
.cv-switch input:checked + i { background: var(--gold); }
.cv-switch input:checked + i::before { transform: translateX(14px); }
.cv-switch input:focus-visible + i { outline: 2.5px solid #fff; outline-offset: 2px; }
.cv-toolbar-spacer { flex: 1 1 auto; min-width: 8px; }
.cv-toolbar .btn { flex: 0 0 auto; align-self: center; color: #d8e2ea; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .09); }
.cv-toolbar .btn:hover { background: rgba(255, 255, 255, .16); }
.cv-toolbar .btn.is-admin { color: #d7f4e8; background: rgba(31, 125, 92, .35); border-color: rgba(140, 218, 191, .25); }
.cv-toolbar .btn.is-admin:hover { background: rgba(31, 125, 92, .52); }
@keyframes chip-pulse {
    0% { box-shadow: 0 0 0 0 rgba(232, 163, 23, .55); }
    70% { box-shadow: 0 0 0 12px rgba(232, 163, 23, 0); }
    100% { box-shadow: 0 0 0 0 rgba(232, 163, 23, 0); }
}
.cv-chip.cv-pulse { animation: chip-pulse 1.4s var(--ease); }

/* ---------- Área de trabalho ---------- */
.cv-workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 20px; padding: 20px; align-items: start; }
.cv-catalog { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.cv-catalog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cv-catalog-head h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.cv-catalog-meta { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.cv-catalog-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cv-search { position: relative; width: min(420px, 100%); }
.cv-search span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #8894a0; font-size: 19px; pointer-events: none; }
.cv-search input { padding-left: 40px; background: var(--white); border-color: var(--line); box-shadow: var(--shadow-xs); }

.cv-view-toggle { flex: 0 0 auto; display: flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); box-shadow: var(--shadow-xs); }
.cv-view-btn { display: grid; place-items: center; width: 34px; height: 30px; border: 0; border-radius: 8px; color: #8894a0; background: transparent; transition: background-color var(--fast), color var(--fast); }
.cv-view-btn:hover { color: var(--ink); background: var(--soft); }
.cv-view-btn[aria-pressed="true"] { color: var(--navy); background: var(--gold-soft); }

.cv-filter-toggle {
    display: inline-flex; flex: 0 0 auto; align-items: center; gap: 8px;
    padding: 9px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-md);
    background: var(--white); box-shadow: var(--shadow-xs);
    font-size: 12.5px; font-weight: 650; color: var(--ink); cursor: pointer; user-select: none;
    transition: border-color var(--fast), background-color var(--fast), color var(--fast);
}
.cv-filter-toggle:hover { border-color: #c7cdd2; }
.cv-filter-toggle input { width: 16px; height: 16px; accent-color: var(--gold-strong); cursor: pointer; }
.cv-filter-toggle:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); color: var(--gold-ink); }

.cv-catalog-filtros { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: -2px; }
.cv-filtro-select {
    display: flex; flex-direction: column; gap: 4px; flex: 1 1 160px; min-width: 140px; max-width: 240px;
}
.cv-filtro-select span {
    font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.cv-filtro-select select {
    min-height: 38px; padding: 7px 30px 7px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-md);
    background: var(--white); box-shadow: var(--shadow-xs); font-size: 13px; font-weight: 650; color: var(--ink);
    cursor: pointer; appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%235b6672' d='M5.5 7.5 10 12l4.5-4.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center; background-size: 16px;
}
.cv-filtro-select select:hover { border-color: #c7cdd2; }
.cv-filtro-select select:focus { border-color: var(--gold); box-shadow: 0 0 0 3.5px rgba(232, 163, 23, .18); }
.cv-filtro-select select:not([value=""]):not(:invalid) { color: var(--ink); }
.cv-filtro-select select option[value=""] { color: var(--muted-2); }
.cv-filtro-limpar {
    flex: 0 0 auto; min-height: 38px; padding: 0 14px; border: 1.5px dashed var(--line); border-radius: var(--radius-md);
    background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 700; cursor: pointer;
    transition: border-color var(--fast), color var(--fast);
}
.cv-filtro-limpar:hover { border-color: var(--red); color: var(--red); }

.cv-free-banner {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    color: #6f3f0a; background: var(--gold-soft); border: 1.5px dashed var(--gold); border-radius: var(--radius-md);
    font-size: 12.5px; font-weight: 650; line-height: 1.4;
}
.cv-free-banner strong { font-weight: 850; }
#aviso-coerencia-venda-limite { display: block; margin-top: 4px; color: #8a5a06; font-weight: 700; }
.cv-free-price-custo {
    display: inline-flex; margin-top: 4px; padding: 2px 7px; border-radius: 6px;
    color: var(--red); background: var(--red-soft); font-size: 10.5px; font-weight: 800; white-space: nowrap;
}
/* Markup (%) do preço sobre o custo — ao lado do preço principal e do
   "Geral". Verde quando o preço cobre o custo, vermelho (mesmo tom do selo
   de Custo) quando o markup é negativo, ou seja, venda abaixo do custo. */
.cv-free-price-markup {
    display: inline-flex; margin-left: 5px; padding: 1px 6px; border-radius: 99px;
    color: var(--green); background: var(--green-soft); font-size: 10.5px; font-weight: 800; white-space: nowrap; vertical-align: middle;
}
.cv-free-price-markup.is-negative { color: var(--red); background: var(--red-soft); }
.cv-free-price-ref .cv-free-price-markup { margin-left: 4px; font-size: 9.5px; padding: 1px 5px; }

.cv-product-list { display: flex; flex-direction: column; gap: 8px; }
.cv-product {
    display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto auto; align-items: center; gap: 14px;
    padding: 12px 16px; background: var(--white); border: 1px solid #e4e9ec; border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs); transition: border-color var(--fast), box-shadow var(--fast);
}
.cv-product:hover { border-color: #d7dde2; box-shadow: var(--shadow-sm); }
.cv-product.is-out-of-stock { border-left: 3px solid var(--red); padding-left: 13px; background: #fffaf9; }
.cv-product.is-out-of-stock .cv-product-name { color: #6b747c; }
.cv-product-media {
    position: relative; width: 52px; height: 52px; display: grid; place-items: center; overflow: hidden; padding: 0;
    border: 1px solid var(--line); border-radius: 11px; color: #8895a1;
    background: linear-gradient(150deg, #f4f7f9, #e7edf1);
}
.cv-product-media span { font-size: 10.5px; font-weight: 900; letter-spacing: -.05em; }
.cv-product-media img { width: 100%; height: 100%; display: block; object-fit: contain; }
.cv-product-media.is-loading::after {
    position: absolute; inset: 0; content: "";
    background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .85) 48%, transparent 76%);
    transform: translateX(-100%); animation: image-loading 1.2s infinite;
}
@keyframes image-loading { to { transform: translateX(100%); } }
.cv-product-media.has-image { cursor: zoom-in; background: #fff; }
.cv-product-media.has-image:hover { border-color: var(--gold); transform: translateY(-1px); }
.cv-product-media.no-image { opacity: .55; }
.cv-product-body { min-width: 0; }
.cv-product-body .code-chip { margin-bottom: 4px; }
.cv-product-name { display: block; overflow: hidden; font-size: 14px; font-weight: 700; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.cv-product-sub { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted-2); font-size: 11px; }
.cv-product-inorder { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; color: #17664f; background: var(--green-soft); font-size: 10px; font-weight: 800; }
.cv-product-stock { text-align: right; }
.cv-product-stock small { display: block; color: var(--muted-2); font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.cv-product-stock strong { display: block; margin-top: 2px; color: var(--green); font-size: 13px; font-weight: 800; }
.cv-product-stock.is-out strong { color: var(--red); }
.cv-product-price { text-align: right; min-width: 92px; font-size: 14.5px; font-weight: 800; }
.cv-free-price { display: inline-flex; flex-direction: column; align-items: flex-end; }
.cv-free-price.is-empty {
    justify-content: center; min-height: 38px; padding: 6px 2px; color: var(--muted-2);
    font-size: 10.5px; font-weight: 700; text-align: right; line-height: 1.3;
}
/* Estado colapsado: parece um preço comum. Sem valor definido mostra só "%";
   depois de confirmado mostra o preço final + um pequeno "×" para reabrir.
   O preço da tabela de referência nunca aparece em nenhum dos dois estados. */
.cv-free-price-chip {
    display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent;
    padding: 2px 0; margin: 0; font: inherit; cursor: pointer; color: inherit;
}
.cv-free-price-chip:disabled { cursor: not-allowed; opacity: .5; }
.cv-free-price-chip:not(.is-set) { color: var(--muted-2); font-size: 13px; font-weight: 800; }
.cv-free-price-chip:not(.is-set):hover { color: #7a5308; }
.cv-free-price-chip.is-set { font-size: 14.5px; font-weight: 800; color: var(--ink); }
.cv-free-price-x {
    flex: 0 0 auto; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
    color: #7a5308; background: var(--gold-soft); font-size: 11px; font-weight: 900; line-height: 1;
}
.cv-free-price-field {
    display: inline-flex; align-items: center; overflow: hidden;
    border: 1.5px solid var(--gold); border-radius: 9px; color: #7a5308; background: var(--gold-soft);
    font-size: 11px; font-weight: 850; transition: border-color var(--fast), box-shadow var(--fast);
}
.cv-free-price-field input { min-width: 56px; height: 34px; min-height: 0; padding: 0 4px 0 9px; border: 0; background: transparent; border-radius: 0; text-align: right; font-size: 13px; font-weight: 800; box-shadow: none; }
.cv-free-price-field > span { flex: 0 0 auto; padding-right: 9px; }
.cv-free-price-field input.invalid { color: var(--red); }
.cv-free-price-field:focus-within { border-color: var(--gold-strong); box-shadow: 0 0 0 3.5px rgba(232, 163, 23, .22); }
.cv-free-price-field:has(input.invalid) { border-color: var(--red); background: var(--red-soft); box-shadow: 0 0 0 3.5px rgba(178, 59, 59, .12); }
.cv-free-price-field:has(input:disabled) { border-color: var(--line); background: var(--soft); color: var(--muted-2); }
.cv-free-price-field input:disabled { cursor: not-allowed; }
/* COERÊNCIA DE VENDA: sugestão geral exibida como referência ao lado do chip,
   quando a sugestão ajustada ao cliente selecionado a substitui como valor
   principal (ver linhaProdutoHtml). Agora é um botão (não mais <small>) —
   clicar abre o histórico de vendas por trás do cálculo (ver
   abrirHistoricoVendas), então precisa de reset de botão + affordance de
   clique além do texto puro que era antes. */
.cv-free-price-ref {
    display: block; margin-top: 2px; padding: 0; border: 0; background: transparent;
    color: var(--muted-2); font-size: 9.5px; font-weight: 700; white-space: nowrap;
    text-decoration: underline dotted; text-underline-offset: 2px; cursor: pointer;
}
.cv-free-price-ref:hover, .cv-free-price-ref:focus-visible { color: var(--gold-ink); }
/* Variante usada dentro do item do carrinho (resumo do pedido) */
.cv-order-item-price-chip { width: 100%; justify-content: flex-end; text-align: right; }
.cv-order-item-price-chip small { display: block; color: var(--muted); font-size: 10.5px; }
.cv-order-item-price-chip strong { display: block; margin-top: 2px; font-size: 16px; }
.cv-product-add { width: 36px; height: 36px; flex: 0 0 auto; border: 0; border-radius: 9px; color: #fff; background: var(--navy); font-size: 20px; line-height: 1; transition: background-color var(--fast), transform var(--fast); }
.cv-product-add:hover:not(:disabled) { background: var(--navy-2); transform: translateY(-1px); }
.cv-product-add:disabled { color: #a3adb5; background: #e4e9ec; cursor: not-allowed; }
.cv-catalog-foot { margin: 2px 2px 0; color: var(--muted-2); font-size: 11px; }

/* ---------- Vista em grade (mesma marcação do item, só reorganizada) ----------
   Só existe a partir de 901px: abaixo disso o layout de lista compacto do
   celular/tablet (ver breakpoints no fim do arquivo) já é o ideal, e como
   ele também estiliza .cv-product por classe simples, isolar a vista em
   grade numa min-width evita qualquer disputa de especificidade entre as
   duas — nenhuma das duas precisa "vencer" a outra, porque só uma existe
   em cada largura. */
@media (min-width: 901px) {
    .cv-product-list.is-grid {
        display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 14px;
    }
    .cv-product-list.is-grid .cv-product {
        grid-template-columns: 1fr auto; grid-template-rows: auto auto auto auto;
        grid-template-areas: "media media" "body body" "stock stock" "price add";
        align-items: start; gap: 4px 10px; padding: 14px;
    }
    .cv-product-list.is-grid .cv-product-media { grid-area: media; width: 100%; height: 108px; border-radius: var(--radius-md); margin-bottom: 6px; }
    .cv-product-list.is-grid .cv-product-body { grid-area: body; }
    .cv-product-list.is-grid .cv-product-name { white-space: normal; }
    .cv-product-list.is-grid .cv-product-stock { grid-area: stock; margin: 2px 0 4px; text-align: left; }
    .cv-product-list.is-grid .cv-product-stock small { display: inline; }
    .cv-product-list.is-grid .cv-product-stock strong { display: inline; margin: 0 0 0 4px; }
    .cv-product-list.is-grid .cv-product-price { grid-area: price; align-self: center; text-align: left; }
    .cv-product-list.is-grid .cv-product-add { grid-area: add; align-self: center; }
    .cv-product-list.is-grid .cv-product-inorder { margin-top: 4px; }
}

/* ---------- Estados (vazio / carregando / erro) ---------- */
.cv-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 56px 24px; color: var(--muted); text-align: center; background: var(--white); border: 1px solid #e4e9ec; border-radius: var(--radius-md); }
.cv-state-icon { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 6px; color: #8a97a2; background: var(--soft); border-radius: var(--radius-lg); font-weight: 900; font-size: 13px; }
.cv-state-title { color: #45525e; font-size: 14px; font-weight: 750; }
.cv-state-desc { max-width: 340px; font-size: 12.5px; line-height: 1.5; }
.cv-state.is-error .cv-state-icon { color: #fff; background: var(--red); }
.cv-state.is-error .cv-state-title { color: var(--red); }
.cv-skeleton { display: flex; flex-direction: column; gap: 8px; }
.cv-skeleton-row { height: 76px; border-radius: var(--radius-md); background: linear-gradient(100deg, #eef1f3 8%, #f7f8fa 28%, #eef1f3 48%); background-size: 200% 100%; animation: skeleton-sweep 1.3s ease-in-out infinite; }
@keyframes skeleton-sweep { 0% { background-position: 180% 0; } 100% { background-position: -20% 0; } }

/* ---------- Painel de pedido ---------- */
.cv-order { position: sticky; top: 156px; max-height: calc(100vh - 176px); display: flex; flex-direction: column; background: var(--white); border: 1px solid #e4e9ec; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.cv-order-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.cv-order-eyebrow { display: block; margin-bottom: 3px; color: var(--gold-ink); font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.cv-order-head h2 { margin: 0; font-size: 19px; }
.cv-order-close { display: none; }
.cv-order-empty { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 30px; color: var(--muted); text-align: center; }
.cv-order-empty div { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 12px; border: 1.5px dashed #bfc9d1; border-radius: var(--radius-lg); font-size: 24px; color: #96a2ac; }
.cv-order-empty strong { color: #45525e; }
.cv-order-empty span { margin-top: 5px; font-size: 12.5px; }
.cv-order-list { flex: 1; min-height: 0; overflow: auto; padding: 6px 22px; }

.cv-order-item { padding: 17px 0; border-bottom: 1px solid var(--line-soft); }
.cv-order-item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cv-order-item-code { display: block; color: var(--gold-ink); font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.cv-order-item-name { display: block; margin-top: 3px; font-size: 14.5px; font-weight: 700; line-height: 1.32; }
.cv-order-remove { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); color: #9a5a5a; background: transparent; font-size: 20px; transition: background-color var(--fast); }
.cv-order-remove:hover { background: var(--red-soft); }
.cv-order-item-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; }
.cv-qty { display: flex; align-items: center; height: 40px; border: 1.5px solid #d8dfe4; border-radius: 9px; overflow: hidden; flex: 0 0 auto; }
.cv-qty button { width: 38px; height: 100%; border: 0; color: var(--navy); background: var(--soft); font-size: 16px; transition: background-color var(--fast); }
.cv-qty button:hover { background: #e6ecf0; }
.cv-qty input { width: 52px; height: 100%; padding: 0; border: 0; border-radius: 0; text-align: center; box-shadow: none; min-height: 0; font-size: 14.5px; }
.cv-order-item-price { text-align: right; }
.cv-order-item-price small { display: block; color: var(--muted); font-size: 10.5px; }
.cv-order-item-price strong { display: block; margin-top: 2px; font-size: 16px; }
.cv-order-item-price .cv-old-price { color: var(--muted-2); text-decoration: line-through; font-size: 10.5px; }
.cv-order-discount { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: #68747f; font-size: 11px; font-weight: 700; }
.cv-order-discount > div { display: flex; align-items: center; width: 140px; height: 40px; padding-left: 10px; border: 1.5px solid #d7dee4; border-radius: 9px; color: var(--green); background: var(--white); font-size: 12.5px; font-weight: 800; transition: border-color var(--fast), box-shadow var(--fast); }
.cv-order-discount input { min-width: 0; height: 100%; min-height: 0; padding: 0 10px 0 4px; border: 0; box-shadow: none; text-align: right; font-size: 14.5px; font-weight: 800; }
.cv-order-discount > div:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3.5px rgba(232, 163, 23, .18); }

.cv-order-foot { flex: 0 0 auto; padding: 16px 22px 20px; border-top: 1px solid var(--line); background: #fbfcfd; }
.cv-order-note { display: block; margin-bottom: 12px; font-size: 11.5px; }
.cv-order-note textarea { resize: vertical; min-height: 60px; font-size: 13px; margin-top: 6px; }
.cv-order-note-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; padding: 10px 12px; border: 1.5px dashed #d7dee4; border-radius: var(--radius-md);
    color: #5c6870; background: var(--soft); font-size: 12px; font-weight: 700; text-align: left;
    transition: border-color var(--fast), background-color var(--fast), color var(--fast);
}
.cv-order-note-toggle:hover { border-color: var(--gold); background: var(--gold-soft); color: var(--gold-ink); }
.cv-order-note-toggle small { color: #8b97a1; font-size: 10.5px; font-weight: 600; }
.cv-order-note-toggle:hover small { color: inherit; }
.cv-order-note-toggle[aria-expanded="true"] { border-style: solid; }
.cv-order-totals { display: grid; gap: 8px; margin: 10px 0 14px; }
.cv-order-totals > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.cv-order-totals > div strong { color: var(--ink); }
.cv-order-totals .cv-order-discount-total, .cv-order-totals .cv-order-discount-total strong { color: var(--green); }
.cv-order-grand { align-items: baseline; padding-top: 10px; border-top: 1px dashed #ccd4da; }
.cv-order-grand strong { font-size: 23px; color: var(--navy); }
.cv-order-hint { margin: 9px 0 0; color: #7b8791; font-size: 10.5px; text-align: center; line-height: 1.4; }
.cv-order-trigger { display: none; }
.cv-order-backdrop { display: none; }

/* ---------- Sheets (diálogo central no PC / gaveta no celular) ---------- */
.cv-sheet { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 22px; }
.cv-sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 17, 28, .62); backdrop-filter: blur(3px); }
.cv-sheet-panel { position: relative; z-index: 1; width: min(620px, 100%); max-height: min(720px, 88vh); display: flex; flex-direction: column; background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); overflow: hidden; animation: sheet-in .18s var(--ease); }
.cv-sheet-panel.cv-sheet-wide { width: min(1040px, 100%); }
.cv-sheet-panel.cv-sheet-image { width: min(880px, 100%); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.cv-sheet-head { flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.cv-sheet-eyebrow { display: block; margin-bottom: 3px; color: var(--gold-ink); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.cv-sheet-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.cv-sheet-close { flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; margin: -4px -4px 0 0; border: 0; border-radius: 50%; color: #64717d; background: transparent; font-size: 24px; line-height: 1; transition: background-color var(--fast); }
.cv-sheet-close:hover { background: var(--soft); }
.cv-sheet-search { flex: 0 0 auto; margin: 16px 24px; }
.cv-sheet-hint { margin: -8px 24px 14px; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.cv-sheet-body { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.cv-sheet-body.cv-product-list { padding: 6px 24px 22px; gap: 8px; }
.cv-sheet-foot { flex: 0 0 auto; padding: 16px 24px; border-top: 1px solid var(--line); background: #f8fafb; }

.cv-sheet-toolbar { flex: 0 0 auto; display: flex; justify-content: flex-end; margin: 0 24px 10px; }

/* Pop-up de histórico de vendas (COERÊNCIA DE VENDA, ver abrirHistoricoVendas
   em app.js) — tabela "em miniatura" do mesmo relatório de vendas/
   movimento.php, com rolagem horizontal própria pra não forçar a página
   inteira a rolar de lado num modal já estreito no celular. */
.cv-hv-scroll { margin: 0 24px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
.cv-hv-table { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.cv-hv-table th, .cv-hv-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.cv-hv-table thead th { position: sticky; top: 0; background: var(--soft); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.cv-hv-table tbody tr:last-child td { border-bottom: 0; }
.cv-hv-table tbody tr:hover td { background: var(--gold-soft); }
.cv-hv-table .cv-hv-num { text-align: right; font-variant-numeric: tabular-nums; }
.cv-hv-table .cv-hv-nome { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
/* Preço real (unitário já líquido do desconto) — coluna de destaque, mesmo
   tom de "atenção" já usado no resto da tela (TABELA LIVRE/COERÊNCIA DE
   VENDA, selo de Custo). */
.cv-hv-table td.cv-hv-real { color: var(--gold-ink); background: var(--gold-soft); font-weight: 800; }
.cv-hv-table thead th.cv-hv-real { color: var(--gold-ink); background: #f6e2b8; }

/* Formulário de cadastro de cliente */
.cv-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 24px 4px; }
.cv-form-grid .cv-form-span2 { grid-column: 1 / -1; }
.cv-form-grid input[readonly] { color: var(--muted); background: var(--soft); }
.cv-suggest-list { margin-top: 6px; max-height: 190px; overflow: auto; border: 1px solid #e4e9ec; border-radius: var(--radius-sm); }
.cv-suggest-list .cv-row { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.cv-suggest-list .cv-row:last-child { border-bottom: 0; }
.cv-form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px 22px; flex-wrap: wrap; }

/* Linhas de lista reutilizadas em vários sheets */
.cv-row { width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 24px; border: 0; border-bottom: 1px solid var(--line-soft); background: var(--white); text-align: left; color: var(--ink); transition: background-color var(--fast); }
.cv-row:hover { background: #f8fafb; }
.cv-row:disabled { opacity: .55; cursor: not-allowed; }
.cv-row.is-selected { background: var(--gold-soft); box-shadow: inset 3px 0 var(--gold); }
.cv-row-avatar { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; color: #fff; background: var(--navy); border-radius: 50%; font-size: 13px; font-weight: 850; }
.cv-row-main { flex: 1; min-width: 0; }
.cv-row-main strong { display: block; overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.cv-row-main span { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.cv-row-side { flex: 0 0 auto; text-align: right; }
.cv-row-side strong { display: block; color: var(--navy); font-size: 15px; }
.cv-row-side span { display: block; margin-top: 4px; font-size: 10.5px; font-weight: 700; }
.cv-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; }
.cv-badge-red { color: #fff; background: var(--red); }
.cv-badge-green { color: #fff; background: var(--green); }
.cv-badge-gold { color: #7a5308; background: var(--gold-soft); }
.cv-badge-neutral { color: #647481; background: var(--line-soft); }
.cv-row-main .cv-row-eyebrow { display: block; margin-bottom: 2px; color: var(--gold-ink); font-size: 10px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.cv-row-side .cv-row-discount { color: var(--green) !important; font-weight: 700; }
.cv-row.is-selected .cv-row-arrow { color: var(--gold-ink); }
.cv-row-arrow { flex: 0 0 auto; color: #9ba7b1; font-size: 18px; }

/* Escolha de tabela de preço */
.cv-row.is-table-selected { color: #164739; background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.cv-row.is-table-selected .cv-row-check { display: grid; place-items: center; width: 26px; height: 26px; color: #fff; background: var(--green); border-radius: 50%; font-size: 13px; }
.cv-row.is-table-free { border-style: dashed; }
.cv-row.is-table-free:not(.is-table-selected) { color: #764113; background: #fff8f0; }
.cv-row-voltar { color: var(--muted); font-weight: 800; background: var(--soft); }
.cv-row-voltar:hover { background: #eef2f5; }

/* ---------- Imagem ampliada ---------- */
.cv-image-stage { flex: 1; min-height: 400px; display: grid; place-items: center; padding: 22px; overflow: auto; background: radial-gradient(circle at center, #fff 0, var(--soft) 72%); }
.cv-image-stage img { max-width: 100%; max-height: 60vh; display: block; object-fit: contain; border-radius: 10px; filter: drop-shadow(0 15px 22px rgba(15, 33, 51, .16)); }
.cv-image-source { display: flex; align-items: center; gap: 16px; padding: 14px 24px; color: var(--muted); background: var(--white); border-top: 1px solid var(--line); font-size: 11.5px; }

/* ---------- Sucesso ---------- */
.cv-success { padding: 40px; text-align: center; }
.cv-success-icon { display: grid; place-items: center; width: 66px; height: 66px; margin: 0 auto 18px; color: #fff; background: var(--green); border-radius: 50%; font-size: 30px; }
.cv-success h2 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.cv-success p { color: var(--muted); font-size: 13.5px; }
.cv-success .btn { margin-top: 18px; }

/* ---------- Painel gerencial ---------- */
.cv-manager-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: #f8fafb; border-bottom: 1px solid var(--line); }
.cv-manager-tools[hidden] { display: none; }
.cv-manager-tools strong { display: block; font-size: 12.5px; }
.cv-manager-tools span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.cv-manager-tabs { display: flex; gap: 6px; padding: 10px 24px; border-bottom: 1px solid var(--line); }
.cv-manager-tab { min-height: 36px; padding: 8px 14px; color: #687581; background: transparent; border: 0; border-radius: 9px; font-size: 12px; font-weight: 800; transition: background-color var(--fast), color var(--fast); }
.cv-manager-tab:hover { background: var(--soft); }
.cv-manager-tab.active { color: #fff; background: var(--navy); }
.cv-manager-layout { min-height: 420px; display: grid; grid-template-columns: 310px minmax(0, 1fr); }
.cv-manager-pane { min-width: 0; display: flex; flex-direction: column; background: #f7f9fa; border-right: 1px solid var(--line); }
.cv-manager-pane-title { padding: 15px 18px 8px; }
.cv-manager-pane-title strong { display: block; font-size: 13px; }
.cv-manager-pane-title span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.cv-manager-search { margin: 0 14px 10px; }
.cv-manager-list { flex: 1; min-height: 0; max-height: 330px; overflow: auto; background: var(--white); border-top: 1px solid var(--line); }
.cv-manager-editor { min-width: 0; max-height: 420px; overflow: auto; background: var(--white); }
.cv-manager-selected { display: flex; align-items: center; gap: 12px; padding: 17px 22px 12px; }
.cv-manager-selected strong { display: block; margin-top: 2px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.cv-manager-selected span { display: block; margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.cv-manager-selected small { color: var(--gold-ink); font-size: 9px; font-weight: 850; letter-spacing: .1em; }
.cv-table-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 4px 22px 18px; }
.cv-table-option { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 62px; padding: 11px 13px; background: #f8fafb; border: 1.5px solid var(--line); border-radius: var(--radius-md); cursor: pointer; transition: border-color var(--fast); }
.cv-table-option:hover { border-color: #b9c7d2; }
.cv-table-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.cv-table-option strong { display: block; overflow: hidden; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.cv-table-option small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.cv-table-option b { flex: 0 0 auto; width: 21px; height: 21px; display: grid; place-items: center; color: #fff; background: #fff; border: 2px solid #b9c4cc; border-radius: 6px; }
.cv-table-option input:focus-visible + span { outline: 2.5px solid rgba(232, 163, 23, .4); outline-offset: 3px; border-radius: 4px; }
.cv-table-option input:checked ~ b { background: var(--green); border-color: var(--green); }
.cv-table-option input:checked ~ b::after { content: "✓"; font-size: 12px; }
.cv-manager-client-config { display: grid; gap: 14px; padding: 4px 22px 20px; }
.cv-manager-status { padding: 11px 13px; color: #5f6d78; background: #f5f7f9; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 11.5px; line-height: 1.4; }
.cv-manager-status.active { color: #17664f; background: var(--green-soft); border-color: #b9ddcf; }
.cv-manager-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.cv-manager-link { display: grid; gap: 4px; padding: 13px; color: #164739; background: var(--green-soft); border: 1px solid #b9ddcf; border-radius: var(--radius-md); }
.cv-manager-link strong { font-size: 12px; }
.cv-manager-link span { color: #4c7768; font-size: 10px; }
.cv-manager-link div { display: flex; gap: 8px; margin-top: 5px; }
.cv-manager-link input { min-width: 0; font-size: 11px; }
.cv-manager-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 24px 19px; background: #f8fafb; border-top: 1px solid var(--line); }
.cv-manager-foot span { color: var(--muted); font-size: 10px; }

/* ---------- Administração de imagens ---------- */
.cv-admin-layout { min-height: 540px; display: grid; grid-template-columns: 370px minmax(0, 1fr); }
.cv-admin-search-pane { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #f8fafb; }
.cv-admin-list { flex: 1; min-height: 0; max-height: 460px; overflow: auto; border-top: 1px solid var(--line); background: var(--white); }
.cv-admin-editor { min-width: 0; padding: 22px; overflow: auto; }
.cv-admin-heading { margin-bottom: 14px; }
.cv-admin-heading h3 { margin: 10px 0 4px; font-size: 19px; line-height: 1.25; }
.cv-admin-heading small { color: var(--muted); }
.cv-admin-preview { position: relative; min-height: 260px; display: grid; place-items: center; margin-bottom: 16px; overflow: hidden; background: radial-gradient(circle at center, #fff 0, var(--line-soft) 78%); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.cv-admin-preview img { max-width: 100%; max-height: 280px; display: block; padding: 14px; object-fit: contain; filter: drop-shadow(0 12px 18px rgba(15, 33, 51, .14)); }
.cv-admin-placeholder { display: flex; align-items: center; justify-content: center; flex-direction: column; color: #82909b; }
.cv-admin-placeholder span { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 8px; background: #e1e8ed; border-radius: var(--radius-md); font-weight: 900; }
.cv-admin-origin { position: absolute; right: 10px; bottom: 10px; max-width: calc(100% - 20px); overflow: hidden; padding: 6px 9px; color: #fff; background: rgba(15, 33, 51, .82); border-radius: 7px; font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.cv-admin-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ===========================================================
   Tablet / desktop compacto (901–1180px)
   =========================================================== */
@media (min-width: 901px) and (max-width: 1180px) {
    .cv-workspace { grid-template-columns: minmax(0, 1fr) 400px; padding: 16px; }
    .cv-order { top: 156px; max-height: calc(100vh - 176px); }
}

/* ===========================================================
   Tablet retrato e abaixo — pedido some da coluna fixa (≤900px)
   =========================================================== */
@media (max-width: 900px) {
    .cv-workspace { grid-template-columns: 1fr; padding-bottom: 100px; }
    .cv-view-toggle { display: none; }
    .cv-order { position: fixed; inset: 0 0 0 0; top: 0; z-index: 25; max-height: none; border-radius: 0; border: 0; transform: translateY(100%); transition: transform .28s var(--ease); }
    .cv-order.is-open { transform: translateY(0); }
    .cv-order-head { padding: max(16px, env(safe-area-inset-top)) 18px 14px; }
    .cv-order-close { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border: 0; border-radius: 50%; color: #64717d; background: var(--soft); font-size: 22px; }
    .cv-order-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .cv-order-backdrop { position: fixed; inset: 0; z-index: 24; display: block; background: rgba(8, 17, 28, .55); opacity: 0; pointer-events: none; transition: opacity .2s; }
    .cv-order-backdrop.show { opacity: 1; pointer-events: auto; }
    .cv-order-trigger {
        position: fixed; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; z-index: 20;
        display: flex; align-items: center; justify-content: space-between; min-height: 58px;
        padding: 10px 18px; border: 0; border-radius: var(--radius-lg); color: #fff;
        background: linear-gradient(125deg, var(--navy), #1e4c82);
        box-shadow: 0 14px 32px rgba(8, 17, 28, .4); text-align: left;
    }
    .cv-order-trigger small { display: block; margin-bottom: 2px; color: #b9cbd9; font-size: 10px; font-weight: 700; }
    .cv-order-trigger strong { display: block; font-size: 15.5px; }
    .cv-order-trigger .cv-order-trigger-total { color: #ffd98a; font-size: 17px; }
}

/* ===========================================================
   Celular (≤760px)
   =========================================================== */
@media (max-width: 760px) {
    body { font-size: 14.5px; }
    input, textarea, select { font-size: 16px; }

    .cv-auth-card { padding: 30px 22px 26px; }
    .cv-auth-card h1 { font-size: 22px; }
    .cv-auth-side { display: none; }

    .cv-header { height: auto; flex-wrap: wrap; row-gap: 8px; padding: 8px 12px; }
    .cv-header-brand strong { display: none; }
    .cv-header-brand small { display: none; }
    .cv-header-actions .btn span.btn-text { display: none; }
    .cv-header-actions .btn { min-width: 40px; padding: 8px 10px; }
    .cv-header-user-name { display: none; }
    .cv-header-stat { display: none; }
    .cv-header-user { padding-left: 6px; margin-left: 2px; }
    .cv-header-search { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
    .cv-header-search input { height: 40px; }

    .cv-toolbar { top: 104px; padding: 10px 12px; }
    .cv-chip { min-width: 140px; padding: 7px 12px; }
    .cv-chip.cv-chip-toggle { min-width: 0; }

    .cv-workspace { padding: 14px 10px 96px; gap: 14px; }
    .cv-catalog-head { align-items: stretch; flex-direction: column; gap: 10px; }
    .cv-catalog-head h1 { font-size: 19px; }
    .cv-catalog-controls { width: 100%; }
    .cv-filter-toggle { justify-content: center; }
    .cv-search { width: 100%; }

    .cv-product {
        grid-template-columns: 46px minmax(0, 1fr) auto auto;
        grid-template-areas: "media body body add" "media stock price add";
        row-gap: 6px; padding: 11px 12px;
    }
    .cv-product-media { grid-area: media; width: 46px; height: 46px; }
    .cv-product-body { grid-area: body; }
    .cv-product-stock { grid-area: stock; display: flex; align-items: baseline; gap: 4px; text-align: left; }
    .cv-product-stock small { margin: 0; }
    .cv-product-stock strong { margin: 0; }
    .cv-product-price { grid-area: price; text-align: right; font-size: 13.5px; }
    .cv-free-price-field input { height: 42px; font-size: 16px; min-width: 70px; }
    .cv-product-add { grid-area: add; align-self: center; width: 44px; height: 44px; border-radius: var(--radius-md); }

    .cv-order-list { padding: 4px 16px; }
    .cv-order-item-controls { flex-wrap: wrap; }
    .cv-qty, .cv-qty input, .cv-qty button { height: 42px; }
    .cv-qty button { width: 42px; }
    .cv-qty input { width: 52px; font-size: 15px; }
    .cv-order-remove { width: 42px; height: 42px; }
    .cv-order-discount > div { width: 140px; height: 42px; }
    .cv-order-discount input { font-size: 16px; }

    .cv-sheet { align-items: flex-end; padding: 0; }
    .cv-sheet-panel { width: 100%; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; border-radius: 0; animation: sheet-in-mobile .2s var(--ease); }
    @keyframes sheet-in-mobile { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
    .cv-sheet-head { padding: max(18px, env(safe-area-inset-top)) 16px 14px; }
    .cv-sheet-search { margin: 14px 16px; }
    .cv-sheet-hint { margin: -6px 16px 12px; }
    .cv-row { padding: 14px 16px; min-height: 66px; }
    .cv-sheet-body.cv-product-list { padding: 6px 16px 18px; }
    .cv-sheet-toolbar { margin: 0 16px 10px; }
    .cv-form-grid { grid-template-columns: 1fr; padding: 16px 16px 4px; }
    .cv-form-actions { padding: 14px 16px 18px; }

    .cv-image-stage { min-height: 0; padding: 14px; }
    .cv-image-stage img { max-height: 68vh; }
    .cv-image-source { flex-direction: column; align-items: flex-start; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); }

    .cv-success { width: 100%; padding: 34px 20px max(26px, env(safe-area-inset-bottom)); }

    .cv-manager-tools { flex-direction: column; align-items: stretch; padding: 11px 16px; }
    .cv-manager-tools .btn { width: 100%; }
    .cv-manager-tabs { padding: 8px 16px; }
    .cv-manager-tab { flex: 1; }
    .cv-manager-layout { min-height: 0; display: block; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
    .cv-manager-pane { border-right: 0; border-bottom: 1px solid var(--line); }
    .cv-manager-list { flex: none; max-height: 240px; -webkit-overflow-scrolling: touch; }
    .cv-manager-editor { max-height: none; overflow: visible; }
    .cv-manager-selected, .cv-table-grid, .cv-manager-client-config { padding-right: 16px; padding-left: 16px; }
    .cv-table-grid { grid-template-columns: 1fr; }
    .cv-manager-actions { flex-direction: column; }
    .cv-manager-actions .btn { width: 100%; }
    .cv-manager-link div { flex-direction: column; }
    .cv-manager-foot { position: sticky; bottom: 0; flex-direction: column; align-items: stretch; gap: 10px; padding: 13px 16px max(16px, env(safe-area-inset-bottom)); }
    .cv-manager-foot .btn { width: 100%; }

    .cv-admin-layout { min-height: 0; display: block; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
    .cv-admin-search-pane { min-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); }
    .cv-admin-list { flex: none; max-height: 240px; -webkit-overflow-scrolling: touch; }
    .cv-admin-editor { padding: 16px 14px max(20px, env(safe-area-inset-bottom)); overflow: visible; }
    .cv-admin-preview { min-height: 230px; }
    .cv-admin-actions { flex-direction: column; }
    .cv-admin-actions .btn { width: 100%; }
}

@media (max-width: 380px) {
    .cv-chip { min-width: 128px; }
}
