/* ── COMPRAS MODULE ─────────────────────────────────── */
#section-leads  { display: none; }
#section-leads.active  { display: block; }
#section-compras { display: none; }
#section-compras.active { display: block; }

#stats-compras {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
#filters-compras {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  align-items: flex-end;
}
#ccount-label { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }

/* Material status widget (OK/PDTE quick badges + text input) */
.mat-cell { display: flex; flex-direction: column; gap: 3px; flex: 1; padding: 1px 3px; }
.mat-row1 { display: flex; align-items: center; gap: 6px; }
.mat-row2 { display: none; align-items: center; gap: 4px; padding-left: 2px; flex-wrap: wrap; }
.mat-cell.mat-expanded .mat-row2 { display: flex; }
.mat-quick { display: flex; gap: 3px; flex-shrink: 0; }
.mat-btn {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
  transition: all .15s;
  background: var(--surface2); color: var(--text-muted);
}
.mat-btn:hover { border-color: var(--border); }
.mat-btn.active-ok   { background: rgba(42,168,110,.18); color: var(--success); border-color: var(--success); }
.mat-btn.active-pdte { background: rgba(255,180,0,.18); color: #ffb400; border-color: #ffb400; }
.mat-text {
  flex: 1; background: transparent; border: none;
  color: var(--text); font-size: 12px; font-family: inherit;
  outline: none; padding: 4px 4px; min-width: 0;
}
.mat-text:focus { background: var(--surface2); border-radius: 3px; }
.mat-sub {
  background: transparent; border: none; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 11px; font-family: inherit;
  outline: none; padding: 2px 4px; min-width: 0;
}
.mat-sub::placeholder { color: var(--text-muted); font-style: italic; }
.mat-sub:focus { background: var(--surface2); border-radius: 3px 3px 0 0; }
.mat-sub-prov { width: 100px; }
.mat-sub-date { width: 120px; color-scheme: light; }
.mat-sub-date.mat-frec-pdte { opacity: 0.35; pointer-events: none; }
.mat-date-wrap { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.mat-date-lbl { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; line-height: 1; }
.mat-toggle {
  margin-left: auto; flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 11px; padding: 1px 5px;
  line-height: 1; border-radius: 3px; transition: transform .15s;
}
.mat-toggle:hover { color: var(--text); background: var(--surface2); }
.mat-cell.mat-expanded .mat-toggle { transform: rotate(180deg); }

/* Material filter rows */
#cmat-filters { display: flex; flex-direction: column; gap: 4px; }
.cmat-filter-row {
  display: flex; align-items: center; gap: 4px;
}
.cmat-filter-row select {
  font-size: 12px; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
.cmat-filter-row .cmat-field  { width: 130px; }
.cmat-filter-row .cmat-value  { width: 90px; }
.cmat-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1;
  padding: 2px 5px; border-radius: 4px;
}
.cmat-remove:hover { color: var(--text); background: var(--surface2); }
.cmat-add-btn {
  font-size: 12px; padding: 4px 10px;
  border: 1px dashed var(--border); border-radius: 6px;
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all .15s;
}
.cmat-add-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Material section dimming when linked product is empty */
.ficha-section.mat-inactive .ficha-section-header { color: var(--text-muted); opacity: .4; }
.ficha-section.mat-inactive .ficha-row { opacity: .35; }

/* Compras table status colors */
.badge-completado { background: rgba(42,168,110,.15); color: var(--success); }
.badge-procesando { background: rgba(79,110,247,.15); color: var(--accent); }
.mat-ok   { color: var(--success); font-weight: 600; }
.mat-pdte { color: #ffb400; font-weight: 700; }

/* Modal compras */
#cmodal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  justify-content: center; align-items: flex-start;
  padding: 20px; overflow-y: auto;
}
#cmodal-overlay.open { display: flex; }
#cmodal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 1020px;
  padding: 20px 24px 16px; position: relative;
  margin: auto;
}
#cmodal-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
#cmodal-close {
  position: absolute; top: 20px; right: 20px;
  background: none; border: none; color: var(--text-muted);
  font-size: 22px; cursor: pointer; line-height: 1;
}
#cmodal-close:hover { color: var(--text); }

#cexport-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
#cexport-bar .export-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
