/* ── Compras ─────────────────────────────────────────────────────────────── */
.stats { grid-template-columns: 1fr 1fr; }
.stat-action { cursor: pointer; border: 1px solid #2d7a3a !important; background: #2d7a3a !important; transition: filter .12s; }
.stat-action:hover { filter: brightness(1.1); }
.stat-action .stat-label { color: rgba(255,255,255,.75) !important; }
.stat-add-btn { font-size: 13px !important; color: #fff !important; font-weight: 500; }
.month-bar { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.month-nav-group { display: flex; align-items: center; gap: 10px; }
.month-label { font-family: var(--mono); font-size: 14px; font-weight: 500; min-width: 150px; text-align: center; }
.nav-btn { width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--border); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; transition: all .12s; }
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.add-btn { font-family: var(--mono); font-size: 11px; padding: 6px 14px; border-radius: 6px; border: 1px solid #2d7a3a; background: transparent; color: #2d7a3a; cursor: pointer; transition: all .12s; }
.add-btn:hover { background: #f0faf2; }

/* cards */
.cards-list { display: flex; flex-direction: column; gap: 8px; }

.compra-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

/* ── header (sempre visível, clicável) ── */
.compra-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; cursor: pointer; user-select: none; gap: 12px; transition: background .1s; }
.compra-header:hover { background: var(--surface2); }
.compra-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.compra-chevron { font-size: 14px; color: var(--muted); transition: transform .2s; flex-shrink: 0; line-height: 1; }
.compra-card.open .compra-chevron { transform: rotate(90deg); }
.compra-date { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.compra-local { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compra-del { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center; transition: all .12s; flex-shrink: 0; }
.compra-del:hover { background: #fde8e8; border-color: #f5aaaa; color: #c0392b; }

/* ── body (expandido) ── */
.compra-body { display: none; border-top: 1px solid var(--border); }
.compra-card.open .compra-body { display: block; }

.compra-fields { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.compra-fields:has(+ .compra-fields-row2) { border-bottom: none; padding-bottom: 4px; }
.compra-fields-row2 { padding-top: 4px; }
.compra-field-full { width: 100%; flex: unset; }
.compra-field { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.compra-field label { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.compra-field select { background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-size: 13px; padding: 6px 10px; outline: none; cursor: pointer; }
.compra-field select:focus { border-color: #2d7a3a; }
.compra-header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto; }
.compra-total-badge { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; }
.compra-excluir-btn { font-size: 12px; padding: 6px 14px; border-radius: 7px; border: 1px solid #c0392b; background: #c0392b; color: #fff; cursor: pointer; white-space: nowrap; font-weight: 500; transition: all .12s; flex-shrink: 0; }
.compra-excluir-btn:hover { background: #a93226; border-color: #a93226; }
.compra-total-input { background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-size: 13px; font-family: var(--mono); padding: 6px 10px; outline: none; width: 100%; box-sizing: border-box; }
.compra-total-input:focus { border-color: #2d7a3a; }
.compra-ver { font-size: 12px; color: #2d7a3a; text-decoration: none; border: 1px solid #2d7a3a; border-radius: 6px; padding: 6px 12px; white-space: nowrap; transition: background .12s; align-self: flex-end; margin-left: auto; }
.compra-ver:hover { background: #f0faf2; }

.compra-desc { display: block; width: 100%; box-sizing: border-box; padding: 12px 16px; border: none; background: transparent; color: var(--text); font-size: 13px; font-family: var(--mono); line-height: 1.6; resize: vertical; min-height: 180px; outline: none; }
.compra-desc:focus { background: var(--surface2); }
.compra-desc::placeholder { color: var(--muted2); }
.compra-local-input { background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-size: 13px; padding: 6px 10px; outline: none; width: 100%; box-sizing: border-box; }
.compra-local-input:focus { border-color: #2d7a3a; }

.empty-cards { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 48px; text-align: center; color: var(--muted); font-size: 13px; }

/* upload modal */
.upload-area { border: 2px dashed var(--border); border-radius: 10px; padding: 32px; text-align: center; cursor: pointer; transition: all .15s; color: var(--muted); font-size: 13px; }
.upload-area:hover, .upload-area.drag { border-color: #2d7a3a; background: #f0faf2; color: #2d7a3a; }
.upload-area input { display: none; }
.upload-preview { width: 100%; max-height: 200px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); }
.upload-analyzing { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 4px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: #2d7a3a; border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-label { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; display: block; }
.form-input { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; padding: 10px 13px; outline: none; width: 100%; box-sizing: border-box; }
.form-input:focus { border-color: #2d7a3a; }
.form-textarea { min-height: 100px; resize: vertical; font-family: var(--mono); line-height: 1.6; }

@media (max-width: 640px) {
  .compra-fields { gap: 10px; }
  .compra-field { min-width: 90px; flex: 1; }
  .compra-ver { margin-left: 0; width: 100%; text-align: center; justify-content: center; display: flex; }
  .compra-fields { flex-wrap: wrap; }
}
