/* Módulo Compras — complementa financas-compact.css */
.compras-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2.5rem;
}

.compras-page .page-header h1 {
    color: #166534;
    font-size: 1.75rem;
    margin-bottom: 0.35rem;
}

.compras-page .page-header .subtitle {
    color: #64748b;
    font-size: 1rem;
    margin: 0;
}

.compras-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.75rem;
}

.compras-card-link {
    display: block;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 8px rgba(22, 101, 52, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex: 1 1 280px;
    max-width: 420px;
}

.compras-card-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(22, 101, 52, 0.15);
    border-color: #86efac;
}

.compras-card-link h2 {
    font-size: 1.15rem;
    color: #15803d;
    margin: 0 0 0.5rem 0;
}

.compras-card-link p {
    margin: 0;
    font-size: 0.95rem;
    color: #475569;
    line-height: 1.5;
}

.compras-card-link .compras-emoji {
    font-size: 1.75rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* Upload */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.texto-section {
    margin-top: 0.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.texto-body {
    padding: 1rem 1.25rem 0.25rem;
}

.texto-nfce {
    width: 100%;
    box-sizing: border-box;
    min-height: 280px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    background: #f8fafc;
}

.texto-nfce:focus {
    outline: none;
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
    background: #fff;
}

.xml-secondary {
    margin-top: 1.25rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.75rem 1.25rem 1rem;
}

.xml-secondary summary {
    cursor: pointer;
    font-weight: 600;
    color: #334155;
    padding: 0.35rem 0;
    list-style-position: outside;
}

.xml-secondary[open] summary {
    margin-bottom: 0.75rem;
    color: #166534;
}

.badge-texto {
    background: #dbeafe;
    color: #1e3a8a;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.badge-xml {
    background: #f3e8ff;
    color: #581c87;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.compras-upload-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2.5rem;
}

.compras-upload-container h1 {
    color: #166534;
    font-size: 1.75rem;
    margin-bottom: 0.35rem;
}

.compras-upload-container .page-desc {
    color: #64748b;
    margin: 0 0 1.5rem 0;
    line-height: 1.5;
}

.upload-area {
    border: 3px dashed #22c55e;
    border-radius: 12px;
    padding: 48px 32px;
    text-align: center;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    margin: 1rem 0;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.upload-area:hover {
    border-color: #16a34a;
    background: linear-gradient(135deg, #dcfce7 0%, #f0fdf4 100%);
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #2563eb;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.upload-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
}

.upload-text {
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 0.35rem;
}

.upload-hint {
    font-size: 0.9rem;
    color: #64748b;
}

.file-input {
    display: none;
}

.queue-section,
.amostras-section {
    margin-top: 1.75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.section-header {
    background: linear-gradient(135deg, #166534 0%, #15803d 100%);
    color: #fff;
    padding: 0.9rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.section-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.file-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.file-list li:last-child {
    border-bottom: none;
}

.file-list li.mes-grupo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    background: #f0fdf4;
    border-bottom: 1px solid #bbf7d0;
    position: sticky;
    top: var(--jarvis-chrome-top, 70px);
    z-index: 2;
}

.mes-grupo-titulo {
    font-weight: 700;
    font-size: 0.95rem;
    color: #166534;
}

.mes-grupo-total {
    font-size: 0.8rem;
    font-weight: 700;
    color: #14532d;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    white-space: nowrap;
}

.file-list li.nota-item + li.mes-grupo-header {
    border-top: 1px solid #e2e8f0;
}

.file-meta {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: #1e293b;
    word-break: break-all;
}

.file-size,
.file-extra {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.file-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-compras {
    border: none;
    border-radius: 8px;
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-compras-primary {
    background: #16a34a;
    color: #fff;
}

.btn-compras-primary:hover:not(:disabled) {
    background: #15803d;
}

.btn-compras-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-compras-secondary {
    background: #e2e8f0;
    color: #334155;
}

.btn-compras-secondary:hover {
    background: #cbd5e1;
}

.btn-compras-danger {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.btn-compras-danger:hover {
    background: #fecaca;
}

.btn-compras.btn-danger-outline {
    background: #fff;
    color: #b91c1c;
    border: 1px solid #f87171;
}

.btn-compras.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

.queue-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-wrap: wrap;
}

.alert {
    padding: 0.9rem 1.1rem;
    border-radius: 8px;
    margin: 1rem 0;
    display: none;
}

.alert.visible {
    display: block;
}

.alert-success {
    background: #dcfce7;
    color: #14532d;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #7f1d1d;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #e0f2fe;
    color: #0c4a6e;
    border: 1px solid #bae6fd;
}

.alert-warn {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ok {
    background: #dcfce7;
    color: #14532d;
}

.badge-dup {
    background: #fef3c7;
    color: #78350f;
}

.badge-err {
    background: #fee2e2;
    color: #7f1d1d;
}

.empty-state {
    padding: 1.5rem 1.25rem;
    color: #64748b;
    text-align: center;
}

.loading-inline {
    display: none;
    text-align: center;
    padding: 1.25rem;
    color: #64748b;
}

.loading-inline.visible {
    display: block;
}

.spinner {
    border: 3px solid #e2e8f0;
    border-top: 3px solid #16a34a;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    animation: compras-spin 0.8s linear infinite;
    margin: 0 auto 0.6rem;
}

@keyframes compras-spin {
    to { transform: rotate(360deg); }
}

.chave-acesso {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin: 0.5rem 0 1.25rem;
}

.stat-chip {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.stat-chip span {
    font-weight: 700;
}

.detalhe-nota {
    margin-top: 1.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.detalhe-meta {
    padding: 1rem 1.25rem;
    display: grid;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: #334155;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.table-wrap {
    overflow-x: auto;
}

.itens-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.itens-table th,
.itens-table td {
    padding: 0.55rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.itens-table th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.itens-table td:nth-child(4),
.itens-table td:nth-child(6),
.itens-table td:nth-child(7) {
    text-align: right;
    white-space: nowrap;
}

.produtos-layout {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 900px) {
    .produtos-layout {
        grid-template-columns: 1.2fr 1fr;
        align-items: start;
    }
}

.produtos-side {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

@media (min-width: 900px) {
    .produtos-side {
        position: sticky;
        top: calc(var(--jarvis-chrome-top, 70px) + 0.5rem);
        max-height: calc(100vh - var(--jarvis-chrome-top, 70px) - 1rem);
        overflow: auto;
    }

    /* Com detalhe aberto, o painel de edição ocupa a coluna; sugestões somem */
    .produtos-side.has-detalhe {
        overflow: hidden;
    }

    .produtos-side.has-detalhe #detalheBox {
        display: flex !important;
        flex-direction: column;
        min-height: 0;
        flex: 1 1 auto;
        max-height: 100%;
        overflow: hidden;
        margin-top: 0;
    }

    .produtos-side.has-detalhe #detalheBox .side-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        padding-bottom: 1rem;
    }

    .produtos-side.has-detalhe #sugestoesSection {
        display: none;
    }
}

.produtos-side.has-detalhe #sugestoesSection {
    display: none;
}

.side-body {
    padding: 1rem 1.25rem 1.25rem;
}

.produto-edit-form {
    display: grid;
    gap: 0.85rem;
}

.produto-edit-form label {
    display: grid;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.produto-edit-form input[type="text"],
.produto-edit-form input[type="number"],
.produto-edit-form select {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 16px;
    font-weight: 400;
    color: #1e293b;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
}

.produto-edit-form select {
    cursor: pointer;
}

.produto-edit-form input[type="text"]:focus,
.produto-edit-form input[type="number"]:focus,
.produto-edit-form select:focus {
    outline: 2px solid rgba(22, 101, 52, 0.35);
    border-color: #166534;
}

.aliases-edit-block {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.25rem;
}

.aliases-edit-title {
    margin: 0;
    font-size: 0.95rem;
    color: #0f172a;
}

.aliases-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.btn-aplicar-sugestoes {
    padding: 0.3rem 0.65rem !important;
    font-size: 0.8rem !important;
}

.aliases-edit-hint {
    margin: 0;
    font-size: 0.8rem;
}

.alias-edit-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    background: #f8fafc;
    display: grid;
    gap: 0.45rem;
}

.alias-edit-top {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.alias-edit-top .alias-edit-nome {
    flex: 1;
    min-width: 0;
}

.alias-edit-top .btn-alias-rm-edit {
    flex-shrink: 0;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
}

.alias-edit-desc {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    word-break: break-word;
}

.alias-edit-nome {
    display: grid;
    gap: 0.3rem;
}

.alias-edit-nome input {
    width: 100%;
    box-sizing: border-box;
}

.alias-edit-codigo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.alias-codigo-label {
    font-weight: 600;
    color: #64748b;
}

.alias-codigo {
    user-select: all;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.2rem 0.45rem;
    font-size: 0.85rem;
}

.btn-copy-codigo {
    appearance: none;
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    color: #334155;
}

.btn-copy-codigo:hover {
    background: #f1f5f9;
}

.alias-edit-conteudo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.alias-sug {
    margin: 0;
    font-size: 0.75rem;
}

#btnFiltroIncompletos.is-active,
#btnFiltroIncompletos[aria-pressed="true"] {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.produto-incompleto .file-name {
    color: #92400e;
}

.produto-parcial .file-name {
    color: #a16207;
}

.produto-edit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: linear-gradient(to top, #fff 70%, rgba(255, 255, 255, 0.92));
    padding: 0.65rem 0 0.15rem;
    border-top: 1px solid #e2e8f0;
}

.file-size .cat-chip {
    margin-top: 0;
    vertical-align: middle;
}

.produto-row {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
}

.prod-check-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 44px;
    flex-shrink: 0;
}

.prod-check-wrap input {
    width: 18px;
    height: 18px;
}

.produto-row.selected-row {
    background: #f0fdf4;
}

.lote-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid #bbf7d0;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.12);
}

.lote-bar[hidden] {
    display: none !important;
}

.lote-bar-count {
    font-weight: 700;
    font-size: 0.85rem;
    color: #166534;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-lote-limpar {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    color: #dc2626;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s;
}

.btn-lote-limpar:hover {
    background: #fecaca;
    border-color: #f87171;
}

.lote-input {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    font-size: 16px;
    min-width: 120px;
    flex: 1 1 120px;
}

.lote-select {
    background: #fff;
    cursor: pointer;
    max-width: 220px;
    flex: 1 1 140px;
}

.lote-input-sm {
    min-width: 72px;
    flex: 0 1 90px;
}

.lote-check {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: #475569;
    white-space: nowrap;
}

body.has-lote-bar .compras-upload-container {
    padding-bottom: 88px;
}

.alias-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.btn-alias-rm {
    border: none;
    background: #fee2e2;
    color: #991b1b;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}

.alias-compra {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 500;
    margin-top: 0.15rem;
    word-break: break-word;
}

.oferta-list {
    list-style: none;
    margin: 0 0 0.85rem;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}

.oferta-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
    color: #9a3412;
}

.oferta-form-toggle {
    margin-bottom: 0.25rem;
}

.btn-oferta-abrir {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}

#formOferta.oferta-form-hidden,
#formOferta[hidden] {
    display: none;
}

.price-chip.oferta-chip {
    background: #ffedd5;
    color: #9a3412;
    border: 1px solid #fdba74;
}

.busca-input {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    font-size: 16px;
    min-width: 140px;
    max-width: 220px;
}

.muted { color: #64748b; font-size: 0.9rem; }
.warn { color: #92400e; background: #fffbeb; padding: 0.5rem 0.75rem; border-radius: 8px; font-size: 0.9rem; }

.merge-cluster {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    background: #f8fafc;
    overflow: hidden;
}

.merge-cluster--warn {
    border-color: #fcd34d;
    background: #fffbeb;
}

.merge-codigos-warn {
    margin: 0.35rem 0 0.5rem;
    font-size: 0.82rem;
}

.merge-codigos {
    font-size: 0.75rem;
    color: #475569;
}

.merge-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.merge-row:hover {
    background: #f1f5f9;
}

.merge-row-names {
    flex: 1;
    min-width: 0;
    font-size: 0.88rem;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.merge-row-score {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

.merge-row-ignore {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #475569;
    cursor: pointer;
}

.merge-row-ignore:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.merge-cluster-detail {
    display: none;
    padding: 0 0.65rem 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.merge-cluster.is-open .merge-cluster-detail {
    display: block;
}

.merge-cluster.is-open .merge-row {
    background: #e2e8f0;
}

.merge-score { font-size: 0.8rem; color: #64748b; margin: 0.5rem 0; }
.merge-check {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    padding: 0.35rem 0;
    font-size: 0.9rem;
}
.merge-check input { margin-top: 0.2rem; width: 18px; height: 18px; }
.merge-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.6rem; }
.merge-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.merge-nome {
    font-size: 16px;
    padding: 0.5rem 0.65rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.sugestoes-section .sugestoes-toggle {
    width: 100%;
    border: none;
    cursor: pointer;
    font: inherit;
}

.sugestoes-section .sugestoes-toggle h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sugestoes-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
    font-size: 0.75rem;
    font-weight: 700;
}

.sugestoes-chevron {
    font-size: 1rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

.sugestoes-section.is-collapsed .sugestoes-chevron {
    transform: rotate(-90deg);
}

.sugestoes-panel {
    padding: 0.75rem 1rem 1rem;
}

.sugestoes-hint {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    line-height: 1.4;
}

.sugestoes-section.is-collapsed .sugestoes-panel {
    display: none;
}

.price-highlight {
    background: #ecfdf5;
    border: 1px solid #86efac;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    color: #14532d;
}
.alias-list { padding-left: 1.1rem; margin: 0.35rem 0 1rem; }
.alias-list code { font-size: 0.8rem; color: #475569; }

/* —— Lista de compras (mobile-first, iPhone 12 mini ~375px) —— */
.lista-page-body {
    /* Chrome fixo: status-bar + main-nav (--jarvis-chrome-top em menu-navegacao.css) */
    padding: var(--jarvis-chrome-top, 70px) 0 0 !important;
    background: #f1f5f9;
}

.lista-app {
    max-width: 1100px;
    margin: 0 auto;
    min-height: calc(100vh - var(--jarvis-chrome-top, 70px));
    padding: 0.75rem 0.75rem calc(88px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

.lista-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.lista-header h1 {
    color: #166534;
    font-size: 1.45rem;
    margin: 0 0 0.15rem;
}

.lista-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.btn-header {
    padding: 0.4rem 0.7rem !important;
    font-size: 0.8rem !important;
    min-height: 36px;
    white-space: nowrap;
}

.warn-chip {
    display: inline-block;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

.warn-chip-parcial {
    background: #fefce8;
    color: #854d0e;
    border-color: #fde68a;
}

.lista-cat-header {
    list-style: none;
    position: sticky;
    top: var(--jarvis-chrome-top, 70px);
    z-index: 3;
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 0.45rem 0.75rem;
    margin: 0.15rem 0;
    font-weight: 800;
    font-size: 0.85rem;
    color: #166534;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lista-cat-count {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
    color: #14532d;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    white-space: nowrap;
}

.lista-cat-right {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-cat-rename {
    appearance: none;
    border: 1px solid #bbf7d0;
    background: #fff;
    color: #166534;
    border-radius: 8px;
    width: 1.85rem;
    height: 1.85rem;
    padding: 0;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-cat-rename:hover {
    background: #f0fdf4;
    border-color: #86efac;
}

.btn-cat-rename:focus-visible {
    outline: 2px solid #166534;
    outline-offset: 2px;
}

/* Cabeçalhos de categoria no catálogo (file-list) */
.file-list li.lista-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    margin: 0.35rem 0.5rem;
    border-bottom: none;
    cursor: pointer;
    user-select: none;
}

.file-list li.lista-cat-header:hover {
    background: #dcfce7;
}

.file-list li.lista-cat-header:focus-visible {
    outline: 2px solid #166534;
    outline-offset: 2px;
}

.lista-cat-left {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.lista-cat-chevron {
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid #166534;
    border-bottom: 2px solid #166534;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
    margin-bottom: 0.15rem;
}

.file-list li.lista-cat-header.is-collapsed .lista-cat-chevron {
    transform: rotate(-45deg);
    margin-bottom: 0;
    margin-left: 0.1rem;
}

/* Modo mercado — foco no corredor */
body.modo-mercado .lista-sub,
body.modo-mercado .lista-freshness,
body.modo-mercado .lista-panel,
body.modo-mercado #btnSugerir,
body.modo-mercado #btnAdd,
body.modo-mercado .row-remove,
body.modo-mercado .price-chip,
body.modo-mercado .media-chip {
    display: none !important;
}

/* Chip de última compra no modo mercado */
.ultima-compra-chip {
    display: inline-block;
    border-radius: 8px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.35rem 0.65rem;
    white-space: nowrap;
    border: 1px solid #fbbf24;
}

.ultima-compra-chip.muted {
    background: #f1f5f9;
    color: #64748b;
    border-color: #cbd5e1;
    font-weight: 500;
}

/* Chip comparativo de preço */
.comparativo-chip {
    display: inline-block;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    margin-left: 0.3rem;
}

.comparativo-chip.preco-melhor {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
    border: 1px solid #86efac;
}

.comparativo-chip.preco-pior {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Navegação de seções/corredores no modo mercado */
.secao-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.secao-nav::-webkit-scrollbar {
    display: none;
}

.secao-nav-inner {
    display: flex;
    gap: 0.5rem;
    padding: 0 0.25rem;
}

.secao-btn {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
}

.secao-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.secao-btn:active {
    transform: scale(0.95);
}

/* Header de categoria no modo mercado - estilo corredor */
body.modo-mercado .lista-cat-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    position: sticky;
    top: 52px;
    z-index: 40;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.3s;
}

body.modo-mercado .lista-cat-header.highlight {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

/* Sparkline de histórico de preços */
.sparkline-wrap {
    display: inline-flex;
    align-items: center;
    margin-left: 0.4rem;
    padding: 0.15rem 0.3rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.sparkline {
    display: block;
}

body.modo-mercado .lista-footer {
    grid-template-columns: 1fr;
}

body.modo-mercado .lista-row {
    min-height: 76px;
    grid-template-columns: 48px 1fr auto;
    padding: 0.55rem 0.45rem;
}

body.modo-mercado .row-name {
    font-size: 1.1rem;
}

body.modo-mercado .check-wrap input {
    width: 26px;
    height: 26px;
}

body.modo-mercado .step-btn {
    width: 36px;
    height: 36px;
}

body.modo-mercado .step-input {
    width: 48px;
    height: 36px;
    font-size: 16px;
}

body.modo-mercado .lista-layout {
    display: block;
}

.lista-sub {
    margin: 0 0 0.35rem;
    color: #64748b;
    font-size: 0.9rem;
}

.lista-freshness {
    margin: 0 0 0.85rem;
    color: #475569;
    font-size: 0.8rem;
    line-height: 1.35;
}

.lista-freshness a {
    color: #166534;
    font-weight: 600;
    text-decoration: none;
}

.lista-freshness a:hover {
    text-decoration: underline;
}

.lista-freshness.stale {
    color: #9a3412;
}

.lista-freshness.stale strong {
    color: #c2410c;
}

.lista-layout {
    display: block;
}

.lista-itens {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.lista-row {
    display: grid;
    grid-template-columns: 44px 1fr auto 36px;
    gap: 0.35rem;
    align-items: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.45rem 0.4rem;
    min-height: 64px;
}

.lista-row.selected {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.lista-row.marcado {
    opacity: 0.55;
}

.check-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
}

.check-wrap input {
    width: 22px;
    height: 22px;
}

.row-main {
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.25rem 0.15rem;
    cursor: pointer;
    min-width: 0;
}

.row-name {
    display: block;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.95rem;
    line-height: 1.3;
    word-break: break-word;
}

.row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.25rem;
    align-items: center;
}

.media-chip {
    display: inline-block;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0c4a6e;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    white-space: nowrap;
}

.cat-chip {
    display: inline-block;
    margin-top: 0.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.media-highlight {
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    color: #0c4a6e;
}

.price-chip {
    display: inline-block;
    border: none;
    border-radius: 999px;
    background: #dcfce7;
    color: #14532d;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.muted-chip { background: #e2e8f0; color: #475569; }

.stepper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    min-width: 0;
}

.stepper-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
}

.stepper-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    line-height: 1.2;
    text-align: center;
}

.stepper-sug {
    font-size: 0.68rem;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.stepper-est {
    font-size: 0.72rem;
    font-weight: 800;
    color: #166534;
    white-space: nowrap;
}

.stepper-meta .muted {
    color: #94a3b8;
    font-weight: 600;
}

.step-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
}

.step-input {
    width: 52px;
    height: 40px;
    text-align: center;
    font-size: 16px; /* mobile: evita zoom no iOS */
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.row-remove {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 1rem;
    min-width: 36px;
    min-height: 44px;
    cursor: pointer;
}

.lista-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) 1fr 1fr;
    gap: 0.5rem;
    align-items: center;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #e2e8f0;
    backdrop-filter: blur(8px);
    z-index: 50;
}

.footer-stats {
    min-width: 0;
}

.footer-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.footer-total {
    font-size: 0.8rem;
    font-weight: 800;
    color: #166534;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-chip {
    display: inline-block;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    text-transform: lowercase;
}

.status-devido {
    background: #fef3c7;
    color: #92400e;
}

.status-atrasado {
    background: #fee2e2;
    color: #991b1b;
}

.est-chip {
    display: inline-block;
    border-radius: 999px;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    white-space: nowrap;
}

.repo-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: #334155;
    display: grid;
    gap: 0.3rem;
}

.footer-btn {
    min-height: 44px;
    font-size: 0.85rem !important;
    padding: 0.55rem 0.5rem !important;
}

.lista-panel {
    display: none;
}

.lista-panel.open {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    max-height: min(70vh, 520px);
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow: auto;
}

.panel-inner { padding: 1rem 1rem 1.25rem; position: relative; }
.panel-close {
    position: absolute;
    top: 0.65rem;
    right: 0.75rem;
    border: none;
    background: #f1f5f9;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    cursor: pointer;
}
.panel-body .ph-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.panel-body .ph-value { font-size: 1.6rem; font-weight: 800; }
.panel-body .ph-value span { font-size: 0.95rem; font-weight: 600; }
.panel-body .ph-loja { margin-top: 0.25rem; font-weight: 600; }
.panel-body .ph-data { font-size: 0.85rem; opacity: 0.85; }
.hist-mini { padding-left: 1.1rem; margin: 0.4rem 0 0; }
.hist-mini li { margin-bottom: 0.55rem; }

.dlg-add {
    border: none;
    border-radius: 14px;
    padding: 1rem 1.1rem;
    width: min(92vw, 420px);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
}
.dlg-add::backdrop { background: rgba(15, 23, 42, 0.45); }
.dlg-add h3 { margin: 0 0 0.75rem; color: #166534; }
.dlg-add .busca-input { width: 100%; max-width: none; box-sizing: border-box; }
.add-results {
    list-style: none;
    margin: 0.75rem 0;
    padding: 0;
    max-height: 240px;
    overflow: auto;
}
.add-results button {
    width: 100%;
    text-align: left;
    border: none;
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.7rem 0.75rem;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
    cursor: pointer;
    min-height: 44px;
}
.dlg-actions { display: flex; justify-content: flex-end; }

@media (min-width: 768px) {
    .lista-app {
        padding: 1.25rem 1.25rem 2rem;
    }

    .lista-layout {
        display: grid;
        grid-template-columns: 1.15fr 0.85fr;
        gap: 1.25rem;
        align-items: start;
    }

    .lista-panel,
    .lista-panel.open {
        display: block;
        position: sticky;
        top: calc(var(--jarvis-chrome-top, 70px) + 12px);
        max-height: none;
        border-radius: 12px;
        border: 1px solid #e2e8f0;
        box-shadow: none;
        background: #fff;
        padding-bottom: 0;
        overflow: visible;
    }

    .panel-close { display: none; }

    .lista-footer {
        position: static;
        margin-top: 1.25rem;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        grid-template-columns: minmax(0, 1.2fr) 1fr 1fr;
        max-width: 640px;
    }

    .lista-row {
        grid-template-columns: 44px 1fr minmax(120px, auto) 40px;
        align-items: center;
    }

    .step-input {
        width: 44px;
        height: 32px;
        font-size: 0.85rem;
        font-weight: 600;
    }

    .step-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .stepper-meta {
        flex-direction: row;
        justify-content: center;
        gap: 0.4rem;
        flex-wrap: wrap;
    }

    .stepper-sug {
        font-size: 0.72rem;
    }

    .stepper-est {
        font-size: 0.78rem;
    }
}
